-
-
Save isa/d7b795670b1b57d38b88b761092b4a23 to your computer and use it in GitHub Desktop.
Flask in Docker - productionised with simplicity
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 | |
# From the python:onbuild image | |
# For discussion of onbuild variant images see: https://hub.docker.com/_/python/ | |
WORKDIR /usr/src/app | |
COPY . /usr/src/app | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Install uWSGI | |
RUN pip install uwsgi | |
# Non-root user | |
# https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#user | |
RUN groupadd -r uwsgi && useradd -r -g uwsgi uwsgi | |
USER uwsgi | |
# Server | |
# | |
# We're using plain HTTP for simplicity but see also "uwsgi_pass" for Nginx: | |
# http://flask.pocoo.org/docs/0.12/deploying/uwsgi/ | |
# | |
# Inspired by: | |
# https://www.smartfile.com/blog/dockerizing-a-python-flask-application/ | |
# | |
# This assumes your main file is called "app.py" and your callable is called "app": | |
ENV PORT 5000 | |
CMD uwsgi --http 0.0.0.0:$PORT --module app:app --processes 1 --threads 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment