Skip to content

Instantly share code, notes, and snippets.

@unfor19
Created February 12, 2021 13:50
Show Gist options
  • Save unfor19/7968c62074ff1f1f2924ae4766cecaed to your computer and use it in GitHub Desktop.
Save unfor19/7968c62074ff1f1f2924ae4766cecaed to your computer and use it in GitHub Desktop.
multi-stage-build-good-dockerfile
# GOOD
FROM python:3.9.1-slim as build
# Upgrade pip and then install build tools
RUN pip install --upgrade pip && \
pip install --upgrade wheel setuptools wheel check-wheel-contents
### Consider the comments as commands
# Copy and install requirements - better caching
# Copy the application from Docker build context to WORKDIR
# Build the application, validate wheel contents and install the application
FROM python:3.9.1-slim as app
WORKDIR /myapp/
COPY --from=build /dist/ /myapp/
ENTRYPOINT ["app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment