Skip to content

Instantly share code, notes, and snippets.

@mrpbennett
Last active February 2, 2022 09:49
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 mrpbennett/dbebabe0d46f0df0c2d6e6b57a11a44c to your computer and use it in GitHub Desktop.
Save mrpbennett/dbebabe0d46f0df0c2d6e6b57a11a44c to your computer and use it in GitHub Desktop.
Flask Docker file
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim-buster
EXPOSE 5000
ENV VAR1=10
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Install & use pipenv
COPY Pipfile Pipfile.lock ./
RUN python -m pip install --upgrade pip
RUN pip install pipenv && pipenv install --dev --system --deploy
WORKDIR /app
COPY . /app
# Switching to a non-root user, please refer to https://aka.ms/vscode-docker-python-user-rights
RUN useradd appuser && chown -R appuser /app
USER appuser
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["/usr/local/bin/gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment