Skip to content

Instantly share code, notes, and snippets.

@KYDronePilot
Created February 27, 2021 15:58
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 KYDronePilot/a97b769dc83bb05c49dbec6b59f5faa0 to your computer and use it in GitHub Desktop.
Save KYDronePilot/a97b769dc83bb05c49dbec6b59f5faa0 to your computer and use it in GitHub Desktop.
Pipenv Dockerfile template
FROM python:3-alpine AS base
WORKDIR /project
ENV PIPENV_VENV_IN_PROJECT=1
RUN pip install --no-cache-dir pipenv
COPY ./Pipfile* ./
# Install/build pipenv environment in separate container to reduce bulk
FROM base AS pipenv_builder
RUN apk add --no-cache \
# <place any packages needed for building PIP deps here>
&& pipenv sync
# Final image
FROM base
ENV PYTHONPATH=/project/src
# Install lightweight versions of build packages with just the shared
# libraries needed
#RUN apk add --no-cache ...
# Copy over the pipenv environment
COPY --from=pipenv_builder /project/.venv ./.venv
# Copy main project files
COPY ./src /project/src/
CMD [ "pipenv", "run", "some-startup-task" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment