Sign inSign up

unit9/python-uwsgi

By unit9

•Updated over 7 years ago

Image for running Python webapps with uWSGI

Image
0

4.2K

unit9/python-uwsgi repository overview

⁠Base image with Python & uWSGI

See unit9/base⁠ for an introduction.

⁠Features

  • Latest, patched Python 2.7, as found in Debian Jessie
  • uWSGI installed, to run your Python web app

⁠Using with your Dockerfile

Pull 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.

⁠License

See the file LICENSE⁠.

Tag summary

Content type

Image

Digest

Size

96.8 MB

Last updated

over 7 years ago

docker pull unit9/python-uwsgi