A builder for a lean, multi-stage Dockerfile for Python web apps — FastAPI, Flask or Django. Choose your Python version, framework and port, and the tool emits an image that builds dependency wheels in one stage and ships a slim runtime that runs as a non-root user.
How it works
The generated Dockerfile uses two stages. The builder stage runs pip wheel to compile every dependency from requirements.txt into a /wheels directory, keeping compilers and headers out of the final image. The runtime stage installs those pre-built wheels with pip install --no-index --find-links=/wheels, sets PYTHONUNBUFFERED=1 and PYTHONDONTWRITEBYTECODE=1, creates a dedicated non-root app user, copies your code, exposes the port and defines an ENTRYPOINT.
Framework start commands
FastAPI is served with uvicorn app.main:app --host 0.0.0.0, Flask with gunicorn --bind 0.0.0.0:PORT app:app, and Django with gunicorn --bind 0.0.0.0:PORT myproject.wsgi:application. Override the start command if your module path differs. The optional HEALTHCHECK calls your /health endpoint using the standard-library urllib, so it adds no extra dependency.
Tips
Keep dependencies in a pinned requirements.txt so builds are reproducible. Add a .dockerignore so caches and secrets are not baked into the image:
__pycache__
*.pyc
.venv
.git
.env
The Debian-based slim base image is chosen deliberately: it works with the prebuilt manylinux wheels most packages ship, avoiding the slow source builds and musl-libc issues common with alpine.