Last active
May 13, 2020 15:59
-
-
Save jjo/edfeb55ce3d393afc4b48311a43a3881 to your computer and use it in GitHub Desktop.
Generic python dockerfile for multistage builds
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
FROM python:3.8-slim as compile-image | |
RUN apt-get update && apt-get install -y --no-install-recommends build-essential gcc && apt-get clean | |
RUN python -m venv /opt/venv | |
ENV PATH="/opt/venv/bin:$PATH" | |
COPY requirements.txt . | |
RUN pip install -r requirements.txt | |
COPY . /app | |
FROM python:3.8-slim as runtime-image | |
COPY --from=compile-image /opt/venv /opt/venv | |
ENV PATH="/opt/venv/bin:$PATH" | |
COPY . /app | |
## Replace my-app.py by yours :) | |
CMD ["/app/my-app.py"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment