Docker
The compose services, probes, scaling and graceful shutdown.
docker-compose.prod.yml is a complete deployment. The pieces, if you deploy them another way:
| Process | Command | Notes |
|---|---|---|
postgres | postgres:17-alpine | The database. Data lives in the pgdata volume. |
migrate | bunx --bun prisma migrate deploy | Before each release. |
redis | redis-server --save '' --appendonly no | Rate limits and caches. No persistence. |
api | bun src/index.ts (apps/api/Dockerfile) | Stateless, scale horizontally. Set WORKER_ENABLED=false when a worker runs. Probes: /healthz, /readyz. |
worker | bun src/worker.ts (same image) | Outbox delivery and housekeeping. One or more: claims use FOR UPDATE SKIP LOCKED. |
web | apps/web/Dockerfile | Static console on nginx. API_UPSTREAM is where /api goes. |
docs | apps/docs/Dockerfile | Static Fumadocs site on nginx. No API proxy, no dependencies. Published on 8081. |
landing | apps/landing/Dockerfile | Static Astro landing page on nginx. PUBLIC_* URLs are baked in at build time. Published on 8082. |
prometheus and alertmanager only start with the monitoring profile
(docker compose --profile monitoring up -d); neither publishes a port.
Probes
The API serves two unauthenticated probes:
GET /healthz— liveness: the process answers. No dependency checks.GET /readyz— readiness: the database answers and the process is not draining. 503 otherwise.
Graceful shutdown
On SIGTERM the API reports draining on /readyz for SHUTDOWN_DRAIN_MS, stops accepting
connections, and gives in-flight requests and the outbox batch up to SHUTDOWN_TIMEOUT_MS.
Housekeeping
Every MAINTENANCE_INTERVAL_MS (60 s) the worker:
- removes expired sessions,
- removes expired rate-limit windows,
- expires stale invitations,
- seals recently-written executions into the hash chain,
- checks the drift window for each decision.
EXECUTION_RETENTION_DAYS deletes older executions; it is 0 (keep forever) by default, because
executions are the audit trail.
First account
The first account is created by signing up in the console; db:seed is for development.
Scaling
The API is stateless and scales horizontally. The worker is a single-leader / multi-follower
model — outbox rows are claimed with FOR UPDATE SKIP LOCKED, so multiple workers coexist
correctly and one crash does not stall the queue.
Secrets
Secrets come from the environment (or a .env file next to docker-compose.prod.yml):
POSTGRES_PASSWORD, API_KEY_PEPPER, CREDENTIALS_ENCRYPTION_KEY, WEBHOOK_SIGNING_SECRET,
WEB_ORIGIN (the public URL of the console), and optionally EMAIL_PROVIDER (resend | sendgrid)
with its RESEND_API_KEY or SENDGRID_API_KEY, and EMAIL_FROM.CREDENTIALS_ENCRYPTION_KEY is the most important one — rotate it without downtime by setting
CREDENTIALS_ENCRYPTION_KEYS_PREVIOUS to the old value, deploying, then running
bun run credentials:rotate from apps/api to re-encrypt everything under the new key.