Last active
December 23, 2021 09:31
-
-
Save un-def/a45a0de4563c69f713cd9c3b2b03cc86 to your computer and use it in GitHub Desktop.
Python Docker multistage build template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG python_version | |
FROM python:${python_version}-alpine AS base | |
FROM base AS builder | |
COPY requirements.txt /tmp/ | |
RUN pip install --target=/tmp/build --no-deps -r /tmp/requirements.txt | |
FROM base | |
ARG python_version | |
WORKDIR /opt/project/ | |
COPY --from=builder /tmp/build/ /usr/local/lib/python${python_version}/site-packages/ | |
COPY project/ project/ | |
CMD ["python", "-m", "project"] |
Author
un-def
commented
Dec 23, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment