Skip to content

jonpas/flask-gunicorn-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask and Gunicorn Docker image

Docker image with only Flask and Gunicorn, to be used with a reverse proxy such as Traefik. No reverse proxy is included in the image.

Currently Alpine Python 3.12 image. If there is interest for a bigger matrix of tags, distributions or other publishing platforms, open an issue.

Setup

Docker Compose

version: '3'

services:
  web:
    image: ghcr.io/jonpas/flask-gunicorn:latest
    volumes:
      - ./app:/app

Application

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")

Reverse Proxy

Traefik

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.

About

Flask and Gunicorn Docker image.

Resources

License

Stars

Watchers

Forks

Packages