Deploy to production
The recommended setup is Docker Compose: PostgreSQL, the API, the Admin Studio and Caddy for automatic HTTPS, on one server.
Requirements
- A Linux server with Docker Engine 24+ and Docker Compose v2 (2 vCPU and 2 GB RAM are enough to start).
- A domain name pointing to the server, for example
cms.example.com. - Ports 80 and 443 open.
Install with Docker Compose
Get the code and create the settings file:
bashgit clone https://github.com/byterings/bytecontent.git cd bytecontent cp .env.production.example .env.productionEdit
.env.production. SetDOMAINand replace every password and token. Generate secrets withopenssl rand -base64 32.Start everything:
bashdocker compose --env-file .env.production -f docker-compose.prod.yml up -d --buildComplete first-run setup (the
SETUP_TOKENprotects it):bashcurl -X POST https://cms.example.com/api/v1/setup \ -H 'content-type: application/json' -H "x-setup-token: $SETUP_TOKEN" \ -d '{"tenantName":"Acme","tenantSlug":"acme","name":"Ada","email":"[email protected]","password":"a long password"}'Sign in at
https://cms.example.com/login.
What runs
| Service | Purpose | Exposed |
|---|---|---|
caddy | HTTPS with automatic certificates, forwards to the Admin Studio | 80, 443 |
admin | Admin Studio and the same-origin /api proxy | internal |
api | REST API. Applies database migrations on start | internal |
postgres | PostgreSQL 17 with a restricted application role | internal |
maintenance | Housekeeping job (run on a schedule) | job |
Both the Admin Studio and the API (including the public API) are served from your domain: https://cms.example.com/api/v1/....
First-run setup from the server
Alternatively, run setup inside the API container without HTTP:
docker compose --env-file .env.production -f docker-compose.prod.yml exec \
-e SETUP_PASSWORD='a long password' api node dist/cli/setup.js \
--tenant-name Acme --tenant-slug acme --name Ada --email [email protected]Schedule maintenance
Run daily, for example from cron at 03:00:
0 3 * * * cd /srv/bytecontent && docker compose --env-file .env.production -f docker-compose.prod.yml run --rm maintenanceIt removes expired sessions, prunes old audit events and purges the trash. See Maintenance & monitoring.
Media storage
By default, uploads are stored in the media Docker volume. To use S3, Cloudflare R2 or MinIO instead, set in .env.production:
STORAGE_DRIVER=s3
S3_BUCKET=my-cms-media
S3_REGION=auto
S3_ENDPOINT=https://<account>.r2.cloudflarestorage.com
S3_ACCESS_KEY_ID=...
S3_SECRET_ACCESS_KEY=...Native install (without Docker)
- Install Node.js 22+ (24 LTS recommended), pnpm 10 and PostgreSQL 16+.
Create the application role and database, build and migrate:
bashpnpm install ADMIN_DATABASE_URL=postgresql://postgres:<pw>@localhost:5432/postgres \ APP_DB_PASSWORD='<strong password>' pnpm db:setup-local cp apps/api/.env.example apps/api/.env # set DATABASE_URL, NODE_ENV=production, SETUP_TOKEN … pnpm build && pnpm db:deployRun the two processes (use systemd or pm2 to keep them running):
bashnode apps/api/dist/main.js # :4000 API_URL=http://localhost:4000 pnpm --filter @bytecontent/admin start # :3000- Put a TLS reverse proxy (Caddy or nginx) in front of port 3000 and set
TRUST_PROXY=trueon the API.
- Serve only over HTTPS and keep
COOKIE_SECURE=true. - Expose only the reverse proxy. Keep the API and PostgreSQL private.
- Set up backups and test a restore.
- Read the security checklist.
Updating
- Take a backup.
git pull, then rundocker compose --env-file .env.production -f docker-compose.prod.yml up -d --build. Migrations run automatically when the API starts.- Check
https://cms.example.com/api/v1/health/ready.
Migrations are forward-only. To roll back, restore the backup into a new database and deploy the previous version.