Skip to content

Instantly share code, notes, and snippets.

@abduakhatov
Last active June 30, 2022 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abduakhatov/3255429b9ed5b2916ea8f15104fef5b0 to your computer and use it in GitHub Desktop.
Save abduakhatov/3255429b9ed5b2916ea8f15104fef5b0 to your computer and use it in GitHub Desktop.
Docker image to limit size of python package. Source `black`
FROM python:3-slim AS builder
RUN mkdir /src
COPY . /src/
RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
# Install build tools to compile dependencies that don't have prebuilt wheels
&& apt update && apt install -y git build-essential \
&& cd /src \
&& pip install --user --no-cache-dir .[colorama,d]
FROM python:3-slim
# copy only Python packages to limit the image size
COPY --from=builder /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH
CMD ["black"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment