Skip to content
Open menu

Deploy

Build the Docker image, set required environment variables, run migrations on release, and roll back.

Nexo Starter ships a Dockerfile for self-hosting. The image runs the Next.js server in standalone output mode. There is no hosted offering; you deploy to your own infrastructure.

Build

docker build -t nexo-starter:1.4.0 .

The build runs pnpm install --frozen-lockfile, the type check, and next build. It does not run migrations and does not need a database. Tag images with the version, not latest, so rollbacks are unambiguous.

Required environment variables

DATABASE_URL=postgres://user:pass@host:5432/db
AUTH_SECRET=<32+ random bytes>
AUTH_URL=https://your-domain.example
BILLING_PROVIDER=stripe        # or paddle

Then set the keys for the provider you chose (STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET, or the Paddle equivalents). For email, set RESEND_API_KEY. For uploads, set S3_ENDPOINT, S3_BUCKET, S3_ACCESS_KEY_ID, and S3_SECRET_ACCESS_KEY. Missing optional variables disable the corresponding feature at boot with a logged warning; missing required variables fail the start.

Postgres

Use a managed Postgres 16 instance or your own. The app needs a single connection string and does not require extensions beyond what the migrations create. Set a connection limit appropriate to your plan; the app opens a bounded pool.

S3-compatible storage

Point the S3 variables at any S3-compatible endpoint. Create the bucket before first boot and grant read/write to the credentials. Uploads are disabled, not broken, when these are unset.

Health check

The image exposes GET /api/health, which returns 200 when the process is up and the database responds to a trivial query, and 503 otherwise. Configure your orchestrator's readiness probe against it. Do not use it as a liveness probe if you want the process to survive a brief database blip.

Migrations on release

Run migrations as a separate step before starting the new container:

docker run --rm --env-file .env.production nexo-starter:1.4.0 pnpm db:migrate

Migrations are forward-only. Run them once per release, from a single instance, before rolling out. The server checks the schema version on boot and refuses to start on a mismatch, which prevents a half-migrated deployment from serving traffic.

Rollback

To roll back, deploy the previous image tag. Because migrations are forward-only, a rollback that crosses a schema change needs a matching down migration, which the kit does not generate automatically; plan schema changes so the previous release can run against the new schema, or roll back the database from a snapshot taken before the release.

Keep the previous two image tags available. A rollback should be a tag change and a restart, not a rebuild.