Day 6: Put it online
Run the API like production — workers, readiness, secrets in .env, JSON logs — and share it with a public URL.
Your API works on your laptop. Today it runs the way a production service does — several worker processes, a database password that isn't in the code, health checks a load balancer can use, one JSON log line per request, the demo-only endpoints switched off — and then you put it on the internet with a public https URL you can open on your phone. No cloud account needed.
What you build
gunicorn with 2 uvicorn workers (
gunicorn.conf.py,WEB_CONCURRENCY). One process per CPU core is the usual start; if a worker crashes, the manager starts a new one.Migrations run once before the workers start (
python -m app.migratein the container's command), so two workers never race to change the schema./healthand/health/ready: liveness (the process answers) and readiness (it can reach the database). The Docker health check uses readiness.Secrets from
.env:start.shgenerates a random 24-character database password into.env, which is listed in.gitignoreand.dockerignore.compose.yamlrefuses to start without it (${DB_PASSWORD:?...}).A JSON access log: one line per request with method, path, status and milliseconds.
Demo endpoints off: the string-built search from Day 2 and the naive orders from Day 3 now return 404.
A Cloudflare quick tunnel (
cloudflared, compose profilepublic): a temporaryhttps://<random>.trycloudflare.comURL that forwards to your API.
The production command
Check configuration, migrate, then exec the server so it becomes PID 1 and receives the stop signal from Docker directly — that's what lets it finish in-flight requests on shutdown.
What we measured
Verify on Docker Desktop:
Through the tunnel, 20 requests each for GET /products/{id}:
Read the full lesson free
This lesson is one of the first 3 in its course, free with an account — the full article, implementation guide and scripts. No card needed.
Already a member? Sign in