Skip to content

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 main branches

  • 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-slim base image.
  • Managing Secrets:
    • What .env is for, what stays out of .env, and what production deployments do instead.
  • 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.