Deploy runbook
Staging and production on Dokploy at The Keep, rollback and backups.
What runs
Each environment is one Dokploy compose service built from docker-compose.deploy.yml: its own postgres (own volume), api, worker (pg-boss), web, dashboard and docs. Traefik terminates tls with Let's Encrypt. Dokploy projects: lehoetel-staging, lehoetel-production and lehoetel-previews.
| staging | production | |
|---|---|---|
| trigger | every merge to main | published release (tag) |
| hosts | staging-lehoetel, app-staging-lehoetel, api-staging-lehoetel, docs-staging-lehoetel | lehoetel, app-lehoetel, api-lehoetel, docs-lehoetel |
SEED | demo | none |
MESSAGING_LIVE | false | true (a channel still needs its provider keys) |
ALLOW_PREVIEW_ORIGINS | true | false |
S3_PREFIX | staging/ | empty |
All hosts are under findmalek.engineer. Health: the api answers /health, every image ships a docker HEALTHCHECK, the deploy job waits for the api /health.
Secrets
App secrets come from Infisical, see secrets: the deploy job exports the staging or prod environment and writes it, with the computed urls and flags, to the Dokploy compose env before deploying. Without the INFISICAL_* settings the env already in Dokploy is used.
Set up from scratch
- optional: the Infisical settings (secrets
INFISICAL_CLIENT_ID,INFISICAL_CLIENT_SECRET, variablesINFISICAL_URL,INFISICAL_PROJECT_ID), see secrets - an api key for a Dokploy user (Dokploy UI, profile, api keys) as repo secret
DOKPLOY_TOKEN, plus repo variablesDOKPLOY_URL,PREVIEW_DOMAIN,DOKPLOY_ENVIRONMENT_ID(previews environment),STAGING_API_URL,PRODUCTION_API_URL DOKPLOY_URL=... DOKPLOY_TOKEN=... TARGET=staging ENVIRONMENT_ID=<env id> node .github/scripts/dokploy-bootstrap.mjs, then again withTARGET=production. It creates the compose service, a random env (secrets, admin password) and the domains, and prints the compose id. Set it as variableDOKPLOY_STAGING_COMPOSE_IDorDOKPLOY_PRODUCTION_COMPOSE_ID. Re-running keeps the env of an existing service- add the provider keys (Resend, Kapso, S3, GlitchTip, OpenObserve) in the compose Environment tab, the keys are listed in
docker-compose.deploy.yml - DNS: a CNAME per host to the server, plus
*.preview-lehoetel
Rollback
Run the release workflow by hand with an older tag. It points the production compose service at that tag and rebuilds it. Migrations only go forward: if a migration must be undone, restore the database from a backup first.
Backups
The backup workflow dumps a database to an S3 bucket every night when BACKUP_DATABASE_URL and the bucket secrets are set. Dokploy can also back up each database to an S3 destination (Settings, S3 destinations, then the database Backups tab). No off-site S3 destination is configured yet, the only local copy lives on The Keep's disks, see the keep. Before the pilot: add a destination (Backblaze B2, R2 or any S3), schedule the staging and production databases to it, and do one restore drill into a scratch database.