A containerized Python development template for building web services with FastAPI, Docker Compose multi-stage builds, and uv for dependency management.
Designed as a reusable starting point - production and infrastructure blocks are scaffolded as commented sections, ready to uncomment when needed.
| Tool | Purpose |
|---|---|
| FastAPI + Jinja2 | API framework + server-side UI |
| uv | Dependency management |
| Docker + Compose | Multi-stage build, local dev |
| Pydantic Settings | Environment-aware config |
| Black + isort + ruff | Formatting and linting |
| mypy | Static type checking |
| pytest | Testing |
docker compose up --build
cp .env.example .env uv sync
python src/app/main.py
Open the repo in VS Code and use "Reopen in Container" - the .devcontainer/devcontainer.json handles the rest. Start the web service via the provided launch.json debug configuration.
| Stage | Purpose | Used by |
|---|---|---|
base |
OS, python, uv, venv skeleton — no source, no deps | All stages |
builder |
Installs production deps into /venv |
production (via COPY --from) |
development |
Full dev tooling, source mounted at runtime | docker compose up |
test |
Runs pytest with coverage | CI pipeline |
production |
Minimal image, pre-built venv | Uncomment when ready to deploy |
Ready to enable when your project needs them:
- Production stage in
Dockerfile- usesCOPY --from=builderfor minimal image app-prodservice indocker-compose.yml- with resource limits and healthchecks- Postgres service with healthcheck and persistent volume
- Docker networking for multi-service communication