Skip to Content
Potik Docs
Runbooks

Deploying with Coolify

The production Compose definition uses published OCI images, a dedicated migration container, and separately provisioned PostgreSQL and Redis. Set application secrets in Coolify's runtime environment or inject them from your secret manager. Keep a record of the release image digests and environment variable names so an operator can redeploy the previous release.

Service profiles

ProfileSettingsServices
CompactEVENTS_MODE=embedded with default replica counts and no worker profileOne web and one API container. The API also runs the outbox relay and queue worker. PostgreSQL and Redis can be private services on the same host.
StandardEVENTS_MODE=standalone and COMPOSE_PROFILES=workerSeparate web, API, and worker containers. PostgreSQL and Redis can run on separate hosts.
ScaledStandard settings with WEB_REPLICAS, API_REPLICAS, and WORKER_REPLICAS set independentlyWeb and API replicas share PostgreSQL, Redis, and signing keys. The proxy balances requests across replicas. Compose scales on one Docker host. A multi-host installation needs an orchestrator or an external load balancer that sends traffic only to ready nodes.

Use the worker profile only with EVENTS_MODE=standalone. In that mode, keep at least one worker running to relay jobs and process notifications. PostgreSQL and Redis must be reachable from every replica, including the migration and worker containers. In Coolify, connect to the intended private service network or use service endpoints reachable from the application network. Keep database and Redis ports off the public proxy. Use encrypted, authenticated database and Redis connections across hosts. For Redis, use a dedicated persistent instance with AOF enabled and eviction disabled.

Configure a release

  1. Create a Docker Compose application with repo path deploy/production/compose.yaml. Configure read access to your image registry if the images are private. Set API_IMAGE, WEB_IMAGE, MIGRATION_IMAGE, and WORKER_IMAGE to fully qualified registry/name@sha256:… references for the same release.
  2. Add the external settings below to the Coolify application. Allow the Compose process to read these runtime settings. Restrict access to the rendered configuration and container environment, which contain credentials.
  3. Set the Coolify web domain to the HTTPS value of APP_ORIGIN and proxy to web port 3000. Set a separate API HTTPS domain and proxy to api port 8080. Preserve the browser's Origin header and allow WebSocket upgrades at /connection/websocket. Point mobile clients to the API HTTPS domain. Omit OAuth callback query strings from access logs.
  4. Select the client-specific Login V2 base URI for the application origin and register <APP_ORIGIN>/auth/callback with the trusted HTTPS ZITADEL issuer. Configure JWT access tokens for the API project, with a confidential browser client and distinct public mobile client as described in the browser and mobile runbooks.
  5. Deploy and confirm the one-shot migrate container exits successfully. API replicas start after migrations complete, and the web service starts after the API is healthy. Probe /healthz and /readyz on both domains. Sign in using a staging account and verify /me, Projects, and a WebSocket connection. For standard or scaled deployments, also check a worker is running and drains a staging notification.
SettingPurpose
DATABASE_URLPostgreSQL connection URL, using verified TLS across hosts. The role must be able to apply the application's migrations.
REDIS_URLAuthenticated private Redis URL, using rediss:// across hosts.
APP_ORIGINExact browser HTTPS origin with no path or trailing slash.
REALTIME_URLwss://<api-domain>/connection/websocket.
OIDC_ISSUER, OIDC_AUDIENCE, OIDC_ADMIN_ORG_IDTrusted HTTPS issuer, API project ID, and trusted ZITADEL organization ID.
OIDC_CLIENT_ID, OIDC_CLIENT_SECRETBrowser OAuth client credentials.
ZITADEL_ORG_ID, ZITADEL_LOGIN_PATIdentity organization ID and private login service account token used only by the web service.
WEB_SESSION_KEY, REALTIME_TICKET_KEYTwo different keys generated separately with openssl rand -base64 32. Share each key across replicas serving the same deployment.
OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERSOptional Go collector endpoint and secret headers. Also accepts OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG.
WEB_TELEMETRY_SAMPLE_RATE, WEB_TELEMETRY_OTLP_ENDPOINTOptional web telemetry. Use a sample rate above zero and a trusted HTTPS collector /v1/metrics endpoint.
TENANCY_MODEsingle by default. Use multi with invitation SMTP settings described in the email runbook.

Use staging to validate the configuration and readiness before switching production traffic. Retain the previous image digests and known-good runtime settings. Keep profiling and internal telemetry endpoints off public proxy routes.

Roll back application containers

Use expand-and-contract database migrations and rehearse that both releases can operate on the expanded schema. Take a PostgreSQL backup before the release. Confirm schema compatibility before choosing an application-only rollback.

  1. Restore the previous API, web, and worker image digest settings in Coolify. Keep the successful migration image and database schema at the installed version.
  2. Redeploy the application services and wait for readiness. With Compose CLI, use docker compose -f deploy/production/compose.yaml up -d --no-deps --wait api web. In the standard or scaled profile, also redeploy the worker with the previous compatible image. Keep the database and Redis volumes intact.
  3. Verify the active images, health and readiness, and a read through the application. Check a safe staging write or existing production synthetic check and verify worker recovery where enabled.

If the prior application is incompatible with the installed schema, plan a forward fix or a separately approved database recovery. Database recovery has a different recovery point from an application-only rollback.

Rehearse

On a disposable Docker host with Docker Compose v2.24.4 or later, OpenSSL, Python 3, and curl, run:

sh tools/integration/check-deployment.sh

The rehearsal validates compact, standard, and scaled rendering, deploys with loopback-only ports in explicit demo mode, switches to a candidate, checks readiness during a database outage, rolls back the service images, and restores a database archive. It verifies that the app reads the backed-up record after restore and excludes a record written after backup. It builds candidate images when their image variables are unset. Set PREVIOUS_API_IMAGE and PREVIOUS_WEB_IMAGE to test actual retained artifacts. Add PREVIOUS_LEGACY_HEALTH=1 for a prior release without container health commands and web probe routes. Without these variables, the rehearsal uses distinct, labeled fixtures built from the candidate to exercise image switching. A staging check with real prior images and an HTTPS ZITADEL development project is still needed to validate release compatibility and provider configuration.

On this page