Coolify
The first deploy and every update on servers run by Coolify - Supabase as its one-click service, docker-compose.coolify.yml for PowerSync and the web apps, and scripts/coolify.ts for staging and production.
Coolify runs the same pieces as the plain Docker setup, with
two differences: its proxy (Traefik) does TLS and routing instead of Caddy, and Supabase comes from
Coolify's one-click template instead of deploy/supabase/install.sh. Two resources sit in one
Coolify project:
| Resource | What | From |
|---|---|---|
| Supabase (a Service) | Postgres, Auth, PostgREST, Storage, Edge Functions, the gateway, Studio | Coolify's Supabase template |
| Listoca (Compose app) | PowerSync and its storage, the web app, the marketing site, the docs | docker-compose.coolify.yml in this repository |
| Host | Goes to | Resource and service |
|---|---|---|
www.example.com | the marketing site | Listoca, marketing (port 3000) |
app.example.com | the web app | Listoca, web (port 3000) |
docs.example.com | the docs | Listoca, docs (port 3000) |
api.example.com | Supabase's gateway: Auth, REST, Storage, Functions | Supabase, supabase-kong (port 8000) |
sync.example.com | PowerSync | Listoca, powersync (port 8080) |
The steps were written against Coolify v4.7.6 (November 2026). In the commands below, <supabase-uuid>
is the Supabase resource's id: it is in the resource's URL in Coolify and at the end of each of its
container names (docker ps).
Before you start
-
A server with Ubuntu LTS (or another distribution Coolify supports), amd64 or arm64. Coolify asks for 2 cores and 2 GB of memory for itself; Supabase alone runs about fifteen containers, so start with 4 GB or more.
-
Coolify installed on it, as root:
curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bashOpen
http://<server-ip>:8000and create the admin account right away: the first account to register becomes the admin. -
DNS: an A record (and AAAA, if the server has IPv6) for each of the five hosts, pointing at the server.
-
On your machine: this repository with
bun installdone, the Supabase CLI, Node 16 or newer, and SSH access to the server.
Staging and production with the script
scripts/coolify.ts does steps 1 to 5 below over Coolify's API and SSH, once per stage. Staging and
production each run on a server of their own. One Coolify can manage both servers, or each stage
can have its own Coolify.
-
The stages. Fill in
deploy/coolify/stages.ts: for each stage, Coolify's address, the server's name in Coolify, the five hosts, and the GitHub App (Coolify → Sources) if the repository is private. -
A token per Coolify: turn on Settings → Advanced → API Access, then make a token under Keys & Tokens → API Tokens with
read,write,deployandread:sensitive. The script reads the passwords Coolify generated, which needsread:sensitive. -
The secrets. Copy
deploy/coolify/secrets.env.exampletodeploy/coolify/staging.envanddeploy/coolify/production.envand fill them in. Both are git-ignored. -
Per stage, staging first:
bun run coolify:setup stagingThen:
bun run coolify:deploy staging
| Command | What it does |
|---|---|
coolify:setup <stage> | The project and the stage's environment; Supabase with step 1's edits and variables; the Listoca resource with step 5's settings, including the web images' build settings. Then it starts Supabase and waits until Auth publishes the signing key. It prints the EAS variables and the RevenueCat webhook. |
coolify:setup <stage> --restart | The same, and Supabase restarts even when nothing changed (after a domain change, for one). Without the flag it restarts only when its compose file or variables changed. |
coolify:deploy <stage> | The migrations through an SSH tunnel and the SQL from step 2, the functions (step 3), then a deployment of the Listoca resource, which builds the web images on the server. When that finishes, it checks every host. |
Both commands can run again. They find the resources by name, and the secrets the script generates
(the signing keys, SEND_EMAIL_HOOK_SECRET, CRON_SECRET, PowerSync's password and admin token)
stay in Coolify's variables, where a second run reads them back. Sandbox purchases count where the
stage sets acceptSandbox (staging), in the functions and in private.settings.
The script can't do these, so they stay manual: Coolify on each server, the DNS records, the GitHub App, RevenueCat's webhook, the EAS variables and the backups. The script works with both the Kong and the Envoy template. It was written against Coolify's API of November 2026; when Coolify refuses a call, the error names the call and Coolify's answer.
1. Supabase
-
In your project: New resource → Services → Supabase. Don't deploy it yet.
-
Check the template. Open Edit Compose File and look at two things:
- The gateway's name. These steps use the Kong template, whose gateway is
supabase-kong. Newer Coolify releases switch to an Envoy gateway namedsupabase-envoy; see The Envoy template for what changes. - The Postgres version. The migrations are tested on Postgres 17
(
major_versioninsupabase/config.toml). Ifsupabase-dbuses asupabase/postgres:15.…image, change it tosupabase/postgres:17.6.1.136now, while its volume is still empty. Never start Postgres 17 on data written by Postgres 15.
- The gateway's name. These steps use the Kong template, whose gateway is
-
The domain. On
supabase-kong, set the domain tohttps://api.example.com:8000(the:8000is the container's port; visitors use 443). -
The signing key. PowerSync checks tokens with Auth's public key from the JWKS endpoint, so Auth must sign them with an asymmetric key (ES256). Supabase's own script makes the key from the JWT secret Coolify generated. Copy the value of
SERVICE_PASSWORD_JWTfrom the resource's Environment Variables, then, in an empty folder on your machine:curl -fsSLO https://raw.githubusercontent.com/supabase/supabase/master/docker/utils/add-new-auth-keys.shprintf 'JWT_SECRET=%s\n' '<SERVICE_PASSWORD_JWT>' > .envsh add-new-auth-keys.shAnswer
Nwhen it asks to update.env. It prints six values:SUPABASE_PUBLISHABLE_KEY,SUPABASE_SECRET_KEY,ANON_KEY_ASYMMETRIC,SERVICE_ROLE_KEY_ASYMMETRIC,JWT_KEYSandJWT_JWKS. Keep them for step 6, then delete the folder. -
Edit Compose File. The template has no place for Listoca's hooks, sign-in providers and function settings. Add the lines below to the
environmentlist of each service. Each line isNAME_IN_THE_CONTAINER=value, and the value is one of two kinds:- Fixed (
GOTRUE_HOOK_SEND_EMAIL_ENABLED=true): the same on every server. Copy it as it is. - A variable (
GOTRUE_EXTERNAL_APPLE_SECRET=${APPLE_SECRET}):${APPLE_SECRET}makes Coolify listAPPLE_SECRETunder Environment Variables, and you fill it in there in step 6. The variable's name is the one on the right of the=, not the container's.
supabase-auth: the template already sets Auth's addresses, its redirect list and which sign-ups are on, all from variables you fill in at step 6 (API_EXTERNAL_URL,GOTRUE_SITE_URL,ADDITIONAL_REDIRECT_URLS,ENABLE_EMAIL_SIGNUP,ENABLE_PHONE_SIGNUP). Don't add lines for those. Add these at the end of itsenvironmentlist, and leave the template's commented-out hook and provider examples as they are:# signing key - "GOTRUE_JWT_KEYS=${JWT_KEYS}" # send-email hook - GOTRUE_HOOK_SEND_EMAIL_ENABLED=true - GOTRUE_HOOK_SEND_EMAIL_URI=http://supabase-kong:8000/functions/v1/send-email - "GOTRUE_HOOK_SEND_EMAIL_SECRETS=${SEND_EMAIL_HOOK_SECRET}" # access-token hook - GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_ENABLED=true - GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_URI=pg-functions://postgres/public/custom_access_token_hook # no second factor - GOTRUE_MFA_TOTP_ENROLL_ENABLED=false - GOTRUE_MFA_TOTP_VERIFY_ENABLED=false # Sign in with Apple - GOTRUE_EXTERNAL_APPLE_ENABLED=true - "GOTRUE_EXTERNAL_APPLE_CLIENT_ID=${APPLE_CLIENT_IDS}" - "GOTRUE_EXTERNAL_APPLE_SECRET=${APPLE_SECRET}" - "GOTRUE_EXTERNAL_APPLE_REDIRECT_URI=${OAUTH_CALLBACK_URL}" # Sign in with Google - GOTRUE_EXTERNAL_GOOGLE_ENABLED=true - "GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_IDS}" - "GOTRUE_EXTERNAL_GOOGLE_SECRET=${GOOGLE_SECRET}" - "GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI=${OAUTH_CALLBACK_URL}" - GOTRUE_EXTERNAL_GOOGLE_SKIP_NONCE_CHECK=trueWhat each group does, and which variables it leaves for step 6:
Group What it does Variables Signing key Auth signs tokens with the ES256 key from step 4, so PowerSync can check them against the public key. The Envoy template has this line already; don't add it twice. JWT_KEYSSend-email hook Auth hands every email to the send-emailfunction (packages/functions) instead of sending it over SMTP, so the template'sSMTP_*variables go unused. The address is the gateway inside Docker's network, not the public domain.SEND_EMAIL_HOOK_SECRET, the same value the functions getAccess-token hook Auth puts the platform role ( app_role, frompublic.user_roles) into every token. The function comes with the migrations in step 2.none No second factor Turns off TOTP (an authenticator app), to match enableTwoFactor: falseinpackages/auth/src/config.ts.none Sign in with Apple CLIENT_IDtakes a comma-separated list: the app's bundle id, and the Services ID once the web signs in with Apple. The secret is only needed for the web.APPLE_CLIENT_IDS,APPLE_SECRET,OAUTH_CALLBACK_URLSign in with Google CLIENT_IDtakes the web, iOS and Android client ids, comma-separated; the secret is the web client's.SKIP_NONCE_CHECKis needed because Google's iOS SDK puts a nonce into the token that the app can't pass on; without it, every sign-in from an iPhone is refused.GOOGLE_CLIENT_IDS,GOOGLE_SECRET,OAUTH_CALLBACK_URLApple and Google share one callback, so both
REDIRECT_URIlines readOAUTH_CALLBACK_URL.supabase-rest: replace the linePGRST_JWT_SECRET=${SERVICE_PASSWORD_JWT}with- "PGRST_JWT_SECRET=${JWT_JWKS}"supabase-storage: add- 'JWT_JWKS=${JWT_JWKS}'.realtime-dev: add- 'API_JWT_JWKS=${JWT_JWKS}'.supabase-edge-functions(the settingspackages/functions/src/env.tsreads; the runtime already providesSUPABASE_URLandSUPABASE_SERVICE_ROLE_KEY):- "SEND_EMAIL_HOOK_SECRET=${SEND_EMAIL_HOOK_SECRET}" - "CRON_SECRET=${CRON_SECRET}" - "MAIL_PROVIDER=${MAIL_PROVIDER:-resend}" - "MAIL_FROM=${MAIL_FROM}" - "RESEND_API_KEY=${RESEND_API_KEY}" - "SITE_URL=${SITE_URL}" - "WEB_URL=${WEB_URL}" - "REVENUECAT_SECRET_KEY=${REVENUECAT_SECRET_KEY}" - "REVENUECAT_WEBHOOK_AUTHORIZATION=${REVENUECAT_WEBHOOK_AUTHORIZATION}" - "REVENUECAT_WEBHOOK_HMAC_SECRET=${REVENUECAT_WEBHOOK_HMAC_SECRET}" # never true in production: sandbox purchases would unlock plans - PAYMENTS_ACCEPT_SANDBOX=false - "PUSH_PROVIDER=${PUSH_PROVIDER:-expo}" - "EXPO_ACCESS_TOKEN=${EXPO_ACCESS_TOKEN}" - "CONTACT_EMAIL=${CONTACT_EMAIL}" - "NEWSLETTER_PROVIDER=${NEWSLETTER_PROVIDER:-resend}" - "RESEND_NEWSLETTER_SEGMENT_ID=${RESEND_NEWSLETTER_SEGMENT_ID}" # the admin area's sync page - "POWERSYNC_URL=${POWERSYNC_URL}" - "POWERSYNC_METRICS_URL=${POWERSYNC_METRICS_URL}" - "POWERSYNC_ADMIN_TOKEN=${POWERSYNC_ADMIN_TOKEN}"Save.
- Fixed (
-
Environment Variables. Fill in the variables, new and existing:
Variable Value SUPABASE_PUBLISHABLE_KEY,SUPABASE_SECRET_KEYfrom step 4 ANON_KEY_ASYMMETRIC,SERVICE_ROLE_KEY_ASYMMETRICfrom step 4 JWT_KEYS,JWT_JWKSfrom step 4 API_EXTERNAL_URLhttps://api.example.comGOTRUE_SITE_URLhttps://www.example.comADDITIONAL_REDIRECT_URLShttps://app.example.com/**,listoca://**ENABLE_EMAIL_SIGNUP,ENABLE_PHONE_SIGNUPfalse: Listoca signs in with Apple and Google onlyOAUTH_CALLBACK_URLhttps://api.example.com/auth/v1/callbackAPPLE_CLIENT_IDScom.listoca.app; add the Services ID once the web signs in with AppleAPPLE_SECRETempty until the web signs in with Apple GOOGLE_CLIENT_IDSthe web, iOS and Android OAuth client ids, comma-separated GOOGLE_SECRETthe web client's secret SEND_EMAIL_HOOK_SECRETecho "v1,whsec_$(openssl rand -base64 32)"; Auth and the functions share itCRON_SECRETopenssl rand -hex 32; keep it for the Vault entry in step 2SITE_URL,WEB_URLhttps://www.example.com,https://app.example.comMAIL_FROM,RESEND_API_KEY,CONTACT_EMAILas in deploy/supabase/functions.env.exampleREVENUECAT_*,EXPO_ACCESS_TOKEN,RESEND_NEWSLETTER_SEGMENT_IDas in deploy/supabase/functions.env.examplePOWERSYNC_URL,POWERSYNC_METRICS_URLhttp://powersync-<listoca-uuid>:8080andhttp://powersync-<listoca-uuid>:9464/metrics, for the admin area's sync pagePOWERSYNC_ADMIN_TOKENopenssl rand -hex 32; the same value as in the Listoca resource (step 7 there)The comments in
deploy/supabase/overrides.env.exampleexplain each Auth value, and Apple and Google where the client ids come from. -
The network. Configuration → General → Connect To Predefined Network: on. PowerSync, in the other resource, reaches the database and the gateway through it.
-
Deploy, and wait until every container is healthy. Then check that Auth publishes the public key:
curl https://api.example.com/auth/v1/.well-known/jwks.jsonThe answer lists a key with
"kty":"EC". An emptykeyslist meansGOTRUE_JWT_KEYSdidn't reachsupabase-auth.
Studio has no domain of its own: the gateway serves it at the root of https://api.example.com,
behind HTTP basic auth with the dashboard login (SERVICE_USER_ADMIN and
SERVICE_PASSWORD_ADMIN). Anyone can reach the password prompt, so keep the long generated
password.
2. The database
The template doesn't publish Postgres's port. Reach it through an SSH tunnel to the container's address on the server:
ssh root@<server> "docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}' supabase-db-<supabase-uuid>"ssh -N -L 15432:<one-of-those-addresses>:5432 root@<server>With the tunnel open, in another terminal (the password is SERVICE_PASSWORD_POSTGRES):
SUPABASE_DB_URL='postgresql://postgres:<SERVICE_PASSWORD_POSTGRES>@localhost:15432/postgres' bun run db:migrateThen run this SQL, through the same tunnel with psql, or in Coolify's terminal for
supabase-db with psql -U postgres:
-- PowerSync's role (made by the migrations); keep the password for step 5
alter role powersync_role with password '<POWERSYNC_ROLE_PASSWORD>';
-- pg_cron calls the functions with these
select vault.create_secret('http://supabase-kong:8000/functions/v1', 'functions_url');
select vault.create_secret('<CRON_SECRET>', 'cron_secret');Make up POWERSYNC_ROLE_PASSWORD with openssl rand -hex 32. Leave
private.settings.accept_sandbox false.
3. The Edge Functions
The template keeps the functions in a folder on the server,
/data/coolify/services/<supabase-uuid>/volumes/functions. Build them, copy the bundles there, and
restart the functions container:
bun run functions:buildrsync -a --include='*/' --include='index.js' --exclude='*' supabase/functions/ root@<server>:/data/coolify/services/<supabase-uuid>/volumes/functions/ssh root@<server> docker restart supabase-edge-functions-<supabase-uuid>The folders main and hello belong to the template; Coolify rewrites them on every deploy, and
the copy leaves them alone. Check with curl https://api.example.com/functions/v1/health.
deploy/supabase/sync-functions.sh doesn't fit here: it restarts a service named functions,
and the template's is supabase-edge-functions.
4. The images
Coolify builds the web app, the marketing site and the docs on the server, from the checkout of
step 5: docker-compose.coolify.yml points each of them at its Dockerfile. Their public settings
are baked in at build time from the Listoca resource's variables, which coolify:setup sets:
| Variable | Value |
|---|---|
VITE_SITE_URL, VITE_SAAS_URL, VITE_DOCS_URL | https://www.example.com, https://app.example.com, https://docs.example.com/docs |
VITE_SUPABASE_URL, VITE_SUPABASE_KEY | https://api.example.com, the publishable key from step 1.4 |
VITE_SITE_INDEXABLE | false on staging |
VITE_SENTRY_ENVIRONMENT | the stage |
the store URLs, VITE_APPLE_TEAM_ID, Sentry, analytics | publicSettings of the stage in deploy/coolify/stages.ts |
A build stops when one of the first five is missing, and the deployment's log names it. With
Include Source Commit in Build on (the script turns it on), the commit becomes SOURCE_COMMIT,
which the web app reports to Sentry as its release.
The builds need memory beside Supabase: bun install and three Vite builds take a few GB while they
run, so give the server 8 GB, or add swap. Coolify can also run the builds on a separate build
server.
The Images workflow builds the same images on GitHub and pushes them to GHCR, for the plain Docker setup. It runs only when started by hand, and Coolify doesn't use it.
5. PowerSync and the web apps
-
New resource → Public or Private Repository (a private one through the GitHub App or a deploy key), this repository, branch
main. -
Build Pack: Docker Compose. Docker Compose Location:
/docker-compose.coolify.yml. -
General → Build pipeline → Preserve repository during deployment: on. PowerSync mounts
./powersync(its config andsync-config.yaml) from the checkout; without this setting the folder is empty and PowerSync doesn't start. -
Advanced → Auto Deploy: off. A push to
mainmust not deploy before its migrations ran (see Updates). -
Advanced → Connect to predefined network: on.
-
Domains, per service:
Service Domain marketinghttps://www.example.com:3000webhttps://app.example.com:3000docshttps://docs.example.com:3000powersynchttps://sync.example.com:8080Leave
powersync-storagewithout a domain. -
Environment Variables:
Variable Value POWERSYNC_ROLE_PASSWORDfrom step 2 SUPABASE_DB_HOSTsupabase-db-<supabase-uuid>SUPABASE_GATEWAY_HOSTsupabase-kong-<supabase-uuid>the build settings as in step 4 POWERSYNC_ADMIN_TOKENthe one the Supabase functions have, for the admin area's sync page; empty turns that page off SERVICE_PASSWORD_POWERSYNCSTORAGEis generated by Coolify.Coolify's proxy sends every path on the sync domain to PowerSync, its admin API (
/api/admin/*) included, so keepPOWERSYNC_ADMIN_TOKENlong and random. -
Deploy. Then check:
- the
powersynclogs show the replication starting; curl https://sync.example.com/probes/livenessanswers;- https://app.example.com and https://www.example.com load;
- a signed-in phone on the Sync plan syncs (Settings → Sync).
- the
6. RevenueCat and the apps
- RevenueCat: point the webhook at
https://api.example.com/functions/v1/revenuecat-webhookwith the value ofREVENUECAT_WEBHOOK_AUTHORIZATION. - The native app: build it with the production env in EAS (
EXPO_PUBLIC_SUPABASE_URLashttps://api.example.com,EXPO_PUBLIC_SUPABASE_KEYas the publishable key,EXPO_PUBLIC_POWERSYNC_URLashttps://sync.example.com, the RevenueCat keys) and submit it (LAUNCH.md). The app on EAS has every variable.
The marketing site's address
deploy/Caddyfile does two redirects that Traefik doesn't do on its own:
-
The other spelling of the host (
example.combesidewww.example.com): add both to themarketingdomain, comma-separated, and pick Redirect to www in the domain settings. Both names need DNS records. -
The trailing slash (
/contact/to/contact): add labels tomarketingindocker-compose.coolify.yml:labels: - traefik.http.middlewares.no-trailing-slash.redirectregex.regex=^(https://[^/]+/.+?)/+(\?.*)?$ - traefik.http.middlewares.no-trailing-slash.redirectregex.replacement=${1}${2} - traefik.http.middlewares.no-trailing-slash.redirectregex.permanent=trueThis assumes Coolify's Escape special characters in labels is on, the default; with it off, write
$$1$$2. Test it withcurl -I https://www.example.com/contact/before you rely on it, because browsers cache a permanent redirect.
Then bun run seo:check https://www.example.com --also example.com checks both.
Backups
- The database: the
supabase-dbcomponent of the Supabase resource has a Backups tab. Add a daily schedule and an S3 storage (Coolify → Storages). Coolify keeps local copies in/data/coolify/backupsand uploads them. This replaces thebackupservice ofdocker-compose.prod.yml. - Storage's files: they live in the template's MinIO (
supabase-minio). Back up its volume, or point Storage at an external S3 bucket. - PowerSync's storage needs no backup: it rebuilds from replication.
Restore into the running database, with PowerSync stopped (stop powersync in the Listoca
resource first, and start it again after):
docker exec -i supabase-db-<supabase-uuid> pg_restore --clean --if-exists -U postgres -d postgres < postgres-<stamp>.dumpRestore once on a spare server before you need it. The dump runs as postgres, which isn't a
superuser in Supabase's image; the restore test shows whether a schema is missing.
Updates
The order is the same as in the Deployment overview, because installed apps
keep running against the new server. bun run coolify:deploy <stage> does all three steps. By
hand:
-
Migrations through the tunnel (step 2). They only add: no renames or drops in the same release (Database).
-
Functions:
functions:build, thersyncand the restart (step 3). -
Redeploy the Listoca resource. That builds the new images and copies the new
powersync/sync-config.yamlin one go. From GitHub Actions or a terminal:curl --request POST "https://<coolify-host>/api/v1/deploy?uuid=<listoca-uuid>&force=false" --header "Authorization: Bearer $COOLIFY_TOKEN"The token comes from Keys & Tokens → API Tokens with only the
deploypermission, once Settings → Advanced → API Access is on. The endpoint takesPOST; older guides showGET, which now answers 405.
Supabase updates on its own schedule: take a backup, then follow Supabase's notes for the version you move to, and keep the edits from step 1.5 in the new compose file.
The Envoy template
Coolify's next template replaces Kong with Envoy and starts on Postgres 17. If your Supabase
resource has supabase-envoy instead of supabase-kong:
- Put the domain on
supabase-envoy, and usesupabase-envoywherever these steps saysupabase-kong: the send-email hook URL, the Vault entryfunctions_url, andSUPABASE_GATEWAY_HOST(supabase-envoy-<supabase-uuid>). GOTRUE_JWT_KEYS, the storage, realtime and functions JWKS are already wired toJWT_KEYSandJWT_JWKS: fill in those two variables and skip those lines in step 1.5. For PostgREST, set the variablePGRST_JWT_SECRETto the value ofJWT_JWKS.API_EXTERNAL_URLalready defaults to the right address; leave it.
Related
- Deployment: the plain Docker setup and the files it uses.
- Database: schema changes installed apps survive, and the replication slot to watch while PowerSync is down.
- The
deploy-and-env-varsskill: adding a setting to an app or to the functions.