Image for running Python webapps with uWSGI
4.2K
See unit9/base
for an introduction.
DockerfilePull unit9/python-uwsgi:latest and customise this example:
from unit9/python-uwsgi:latest
maintainer You <[email protected]>
# Install backend app requirements
add requirements.txt /app
run pip install -r ./requirements.txt
# Service definition for runit
add run_my_app /etc/service/my_app/run
env PORT=5000
expose 5000
# Add the rest of app code
add . /app
Notice that neither cmd or exec are defined; the unit9/base
image has a simple init system that runs services, as defined in
/etc/service/*/run; see runit for details.
Inside the file run_my_app, there should be a shell script that
reads the environment and sets up the uWSGI service. For example:
#!/bin/sh
set -eu
export DEBUG=${DEBUG:-0}
cd /app
exec chpst -u app \
uwsgi_python27 \
--master \
--http-socket :$PORT \
--processes ${UWSGI_PROCESSES:-2} \
--threads ${UWSGI_THREADS:-32} \
--module backend \
--callable app
Note that your uWSGI process should be running as the user app! This
is not a strict requirement, but it's good for security. The user
already exists in this image.
See the file LICENSE.
Content type
Image
Digest
Size
96.8 MB
Last updated
over 7 years ago
docker pull unit9/python-uwsgi