Python UWSGI
uWSGI is an HTTP server written in C that uses the uwsgi protocol. Many programs written in Python interface with the internet through this server.
For details on the server itself or the protocol, see here.
Installation
Most Linux operating systems offer both the server and the Python plugin as a package. Try installing uswgi and uwsgi-python3, or uwsgi-python for the Python 2 version.
Alpine Linux
If using Python 2, note that Alpine Linux has dropped support for the corresponding software. The last version to offer a uwsgi-python package is 3.10.
For Dockerfiles, consider the below a template:
FROM alpine:3.10 RUN apk add python uwsgi uwsgi-python RUN addgroup -S -g 82 www-data && adduser -S -u 82 -D -h /var/www -s /sbin/nologin www-data COPY --chown=www-data:www-data local/path/to/app /app WORKDIR /app EXPOSE 9000 ENTRYPOINT ["/usr/sbin/uwsgi"] CMD ["--ini", "/app/uwsgi.ini"]
Configuration
uWSGI requires a configuration file to run, typically named uwsgi.ini. A basic one looks like:
[uwsgi] uid = www-data gid = www-data socket = :9000 plugin = python chdir = /app/example.com wsgi-file = /app/example.com/example.wsgi master workers = 3 max-requests = 200 harakiri = 60 die-on-term
The wsgi-file is the Python program that will be served.