Docker image with only Flask uWSGI, to be used with a reverse proxy such as Traefik. No reverse proxy is included in the image.
Currently Alpine Python 3.11 image. If there is interest for a bigger matrix of tags, distributions or other publishing platforms, open an issue.
[Warning! uWSGI allocates memory by system's max fd size, which is often 1073741816
, resulting in high memory usage right out of the box! Gunicorn image is instead recommended for Docker use.](grafana/oncall#1521 (comment))
version: '3'
services:
web:
image: ghcr.io/jonpas/flask-uwsgi:latest
volumes:
- ./app:/app
web/app.py
:
from flask import Flask
from werkzeug.middleware.proxy_fix import ProxyFix
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
if __name__ == "__main__":
app.run(host="0.0.0.0")
web/wsgi.py
:
from web import app
if __name__ == "__main__":
app.run()
wsgi.py
is required for uWSGI to start correctly, however the application/folder name can be your own (web
used as an example).
Setup a rule, an entrypoint and any TLS configuration you require. Service port will be 8000
automatically as the only one exposed in the container.