11. Deployment Best Practices
The application works on localhost.
Getting from localhost to a deployed service needs:
- Command-line tooling so the codebase stays clean as it grows
- A container so the same artifact runs in production that ran in development
- A workflow around secrets
-
A continuous-integration workflow to prevent broken
mainbranches -
Quality Checks:
- Running Ruff, mypy, pytest, and coverage from the command line, and the dev dependencies that make them part of the project.
- Dockerizing a FastAPI App:
- A small, production-ready Dockerfile built around uv and the
python:3.14-slimbase image.
- A small, production-ready Dockerfile built around uv and the
- Managing Secrets:
- What
.envis for, what stays out of.env, and what production deployments do instead.
- What
- GitHub Actions:
- A working CI workflow that runs the same checks contributors do locally.
- Exercise:
- Build the Dockerfile, run the stack with
compose.app.yaml, and confirm the app comes up with a Postgres container.
- Build the Dockerfile, run the stack with