Chapter 27: Publishing and Deployment
ASP.NET Core deployments publish build output. Python deployments usually install your package and run an ASGI server.
Common production options:
- Container image running Uvicorn or Granian.
- Platform-as-a-service deployment.
- VM with systemd and reverse proxy.
- Kubernetes with health checks and config injection.
Container outline:
FROM python:3.12-slim
WORKDIR /app
COPY pyproject.toml ./
COPY src ./src
RUN pip install .
CMD ["uvicorn", "recipevault.main:app", "--host", "0.0.0.0", "--port", "8000"]
Deployment checklist:
- Set
SECRET_KEY, database URL, allowed hosts, and CORS origins. - Run migrations before serving new code.
- Serve static files through a CDN or reverse proxy when appropriate.
- Use multiple workers for CPU-bound or blocking sync workloads.
- Add liveness and readiness endpoints.
- Capture logs centrally.
- Monitor errors and latency.
Do not rely on --reload outside development.