mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
1.9 KiB
1.9 KiB
Production Deployment (Docker Compose)
This project's production Compose stack is intentionally separate from local development.
1) Configure production environment
Create .env.prod from the example and set real values:
cp .env.prod.example .env.prod
Required fields:
APP_IMAGE(immutable tag or digest from CI, for exampleghcr.io/<owner>/<repo>:sha-<commit>)POSTGRES_USERPOSTGRES_PASSWORDPOSTGRES_DBJWT_SECRETAPP_URL
2) Deploy
docker compose --env-file .env.prod -f docker-compose.prod.yml pull
docker compose --env-file .env.prod -f docker-compose.prod.yml up -d --wait
What happens:
postgresstarts withpgvectorenabled via init SQL.migrateruns once (node dist/scripts/migrate.js) and must complete successfully.appstarts only after DB health ishealthyand migration service exits successfully.
3) Roll forward
- Update
APP_IMAGEin.env.prodto the new immutable image. - Pull + restart:
docker compose --env-file .env.prod -f docker-compose.prod.yml pull
docker compose --env-file .env.prod -f docker-compose.prod.yml up -d --wait
4) Backup strategy
Create a compressed custom-format Postgres backup:
pnpm db:backup:prod
By default this writes to local/backups/.
Recommended cadence:
- Daily backups
- Keep at least 7 daily + 4 weekly + 3 monthly snapshots
- Store a copy off-host
5) Restore strategy
Restore into the live DB:
pnpm db:restore:prod -- local/backups/<file>.dump
Run a non-destructive restore test into a temporary DB:
pnpm db:restore:test:prod -- local/backups/<file>.dump
Run the restore test at least monthly so backup integrity is continuously verified.
6) CI image pipeline
Workflow: .github/workflows/container-image.yml
On main and tag pushes it:
- builds the Docker image
- pushes immutable tags to GHCR (
sha-*)