Skip to content

Commit 0a628d2

Browse files
Refactor Dockerfile with best practices (soxoj#691)
Multiple best practices applied as below: - Replace deprecated `MAINTAINER` with `LABEL maintainer` - Remove additional `apt clean` as it'll be done automatically - Use `apt-get` instead of `apt` in script, apt does not have a stable CLI interface, and it's for end-user. - Put `apt-get install` & apt lists clean up in the same command - Use `--no-install-recommends` with `apt-get install` to avoid install additional packages - Use `--no-cache-dir` with `pip install` to prevent temporary cache - Use `COPY` instead of `ADD` for files and folders - Use spaces instead of mixing spaces with tabs to indent Size change by the refactor, almost 100MB saved: ``` REPOSITORY TAG IMAGE ID CREATED SIZE maigret after 9e70c65dde32 1 minutes ago 543MB maigret before a683f2b71751 7 minutes ago 635MB ```
1 parent f1969a1 commit 0a628d2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Dockerfile

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
FROM python:3.9-slim
2-
MAINTAINER Soxoj <soxoj@protonmail.com>
2+
LABEL maintainer="Soxoj <soxoj@protonmail.com>"
33
WORKDIR /app
4-
RUN pip install --upgrade pip
5-
RUN apt update && \
6-
apt install -y \
4+
RUN pip install --no-cache-dir --upgrade pip
5+
RUN apt-get update && \
6+
apt-get install --no-install-recommends -y \
77
gcc \
88
musl-dev \
99
libxml2 \
1010
libxml2-dev \
11-
libxslt-dev
12-
RUN apt clean \
13-
&& rm -rf /var/lib/apt/lists/* /tmp/*
14-
ADD . .
15-
RUN YARL_NO_EXTENSIONS=1 python3 -m pip install .
11+
libxslt-dev \
12+
&& \
13+
rm -rf /var/lib/apt/lists/* /tmp/*
14+
COPY . .
15+
RUN YARL_NO_EXTENSIONS=1 python3 -m pip install --no-cache-dir .
1616
ENTRYPOINT ["maigret"]

0 commit comments

Comments
 (0)