mirror of
https://github.com/soxoj/maigret.git
synced 2026-05-06 22:19:01 +00:00
Refactor Dockerfile with best practices (#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 ```
This commit is contained in:
+9
-9
@@ -1,16 +1,16 @@
|
|||||||
FROM python:3.9-slim
|
FROM python:3.9-slim
|
||||||
MAINTAINER Soxoj <soxoj@protonmail.com>
|
LABEL maintainer="Soxoj <soxoj@protonmail.com>"
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --no-cache-dir --upgrade pip
|
||||||
RUN apt update && \
|
RUN apt-get update && \
|
||||||
apt install -y \
|
apt-get install --no-install-recommends -y \
|
||||||
gcc \
|
gcc \
|
||||||
musl-dev \
|
musl-dev \
|
||||||
libxml2 \
|
libxml2 \
|
||||||
libxml2-dev \
|
libxml2-dev \
|
||||||
libxslt-dev
|
libxslt-dev \
|
||||||
RUN apt clean \
|
&& \
|
||||||
&& rm -rf /var/lib/apt/lists/* /tmp/*
|
rm -rf /var/lib/apt/lists/* /tmp/*
|
||||||
ADD . .
|
COPY . .
|
||||||
RUN YARL_NO_EXTENSIONS=1 python3 -m pip install .
|
RUN YARL_NO_EXTENSIONS=1 python3 -m pip install --no-cache-dir .
|
||||||
ENTRYPOINT ["maigret"]
|
ENTRYPOINT ["maigret"]
|
||||||
|
|||||||
Reference in New Issue
Block a user