Created
October 27, 2020 15:54
-
-
Save esys/26e65eb89a245c2b333c10a25e73f355 to your computer and use it in GitHub Desktop.
Python Flask HelloWorld Dockerfile
This file contains hidden or 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.7-alpine as builder | |
# install dependencies required to build python packages | |
RUN apk update && apk add --no-cache make gcc && pip install --upgrade pip | |
# setup venv and download or build dependencies | |
ENV VENV="/venv" | |
ENV PATH="${VENV}/bin:${PATH}" | |
COPY requirements.txt . | |
RUN python -m venv ${VENV} \ | |
&& pip install --no-cache-dir -r requirements.txt | |
FROM python:3.7-alpine | |
# setup venv with dependencies from the builder stage | |
ENV VENV="/venv" | |
ENV PATH="${VENV}/bin:$PATH" | |
COPY --from=builder ${VENV} ${VENV} | |
# copy app files | |
WORKDIR /app | |
COPY app . | |
# run the app | |
EXPOSE 5000 | |
ENV FLASK_APP="hello.py" | |
CMD [ "flask", "run", "--host=0.0.0.0" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment