Runbook: bringing up and operating the base infrastructure
Bring-up procedure, manual steps, operating and troubleshooting.
How to take an empty Coolify host to a running Fortspace platform (bastion/, Pulumi project
base), what to do by hand, how to operate it afterwards, and what goes wrong. Written from the
first real bring-up of the prod stack (fortspace.eu); every entry in
Troubleshooting is something that actually happened.
Design background is in 09 (layout, edge), 08 (Postgres, secrets) and 03 (identity). This page is the procedure.
At a glance
| Tool | Pulumi project base (bastion/), through scripts/pulumi.sh (never a bare pulumi) |
| Runs from | an operator workstation (Linux x64), against the Coolify API and the public URLs — and, for the control plane, GitHub Actions |
| Stack | prod (platform domain fortspace.eu, Coolify https://coolify.remis-lab.com, server localhost) |
| State | an object storage bucket (S3-compatible, EU), passphrase-encrypted, versioned — see 4 |
| Creates | projects fortspace-platform, fortspace-data-pool; core Postgres + Redis; Mailpit, Zitadel, Infisical, LiveKit + Egress, RustFS; control plane (migrate, api, worker, console) |
| Does not create | DNS, frp/Caddy, the Coolify install itself, tenant projects (control plane), the pocket-id used for the Mailpit login |
| Order | base up → enable Postgres TLS → platform setup → people → control plane up |
What you must not lose
| Item | Where it is | Why it matters |
|---|---|---|
| Pulumi state | the object storage bucket (s3://<bucket>/…, EU, versioned) — the live copy. bastion/.state/ is the pre-migration snapshot |
The stack’s memory of what exists and every generated password. Lose it and Pulumi no longer knows the platform; the passwords are only recoverable from the running containers. The bucket is outside the platform (ADR-029): keep a copy off the account too. |
| Pulumi passphrase | bastion/.env.local (PULUMI_CONFIG_PASSPHRASE), the GitHub Environment prod, offline escrow |
Decrypts the state and every secure: value in Pulumi.prod.yaml. Without it both are junk. |
Infisical ENCRYPTION_KEY / AUTH_SECRET |
stack output (pulumi stack output --show-secrets) → offline escrow |
Losing them loses every secret in Infisical. Never stored in Infisical itself. |
| Zitadel masterkey | stack output → offline escrow | Losing it loses the IdP’s encrypted data. Exactly 32 characters, forever. |
| Zitadel session cookie secret | stack output zitadel.sessionCookieSecret → offline escrow |
The key the Login UI signs its browser sessions with (since v4.19.2). Rotating it signs everyone out of the Login UI; losing it means the Login UI cannot verify its own cookies. |
INFISICAL_ADMIN_PASSWORD |
password manager | The instance-admin break-glass. |
| Coolify local account | password manager (+ MFA) | The only way in when Zitadel is down (10). |
| Mailpit OIDC client secret + session key | offline escrow | Baked into the Mailpit compose; the state holds them encrypted. |
GHCR token (base:registryToken) |
GitHub, plus the encrypted config | Classic PAT, read:packages. Recreate if lost. |
Pulumi.prod.yaml is committed on purpose (it holds the ciphertext); the passphrase is the only
key to it.
1. Prerequisites
Accounts and access
- Coolify (self-hosted) with the API enabled and an API token of the root team with
abilities
read,write,deploy,read:sensitive,delete. Treat it as root on the host. - SSH to the Coolify host (
BASTION_SSH_TARGET=user@host). Needed on the first platform setup only (to read the Zitadel bootstrap PAT) and for the checks in this runbook. - GitHub: a classic PAT with
read:packagesfor the private images (ghcr.io/fortspace/control-plane-*). Fine-grained tokens are not accepted by GHCR. - An object storage bucket (S3-compatible, EU) for the Pulumi state, versioning on, with a bucket-scoped key (4.1).
- GitHub: a GitHub App installed on the
bastionrepository only, and aprodEnvironment inbastionwith the deploy secrets (4.4). - DNS control for the platform domain; control of the frp/Caddy edge.
Workstation: Linux x64 (the Pulumi CLI checksum is pinned for it), Node, pnpm (for
control-plane/), jq, openssl, ssh. control-plane/ must be checked out next to bastion/
(../control-plane): the platform setup runs from there.
Edge, before the first up (outside this program, 09):
| What | Value |
|---|---|
| DNS (Scaleway) | *.<domain> → public VPS; livekit.<domain> must point at the VPS directly, never through an HTTP proxy (UDP media) |
| frp (HTTP) | public 80/443 → the Coolify host’s Traefik (behind Caddy: frps on 8443/8080) |
| frp (media) | public TCP 7885 / UDP 7886 → host 7883 / 7884 → container 7881 / 7882 |
frp routes TCP/UDP by port, never by domain. A second LiveKit needs its own public port pair:
the old office-suite prototype keeps 7881/7882, so prod uses 7885/7886. You edit frpc
yourself; the stack only publishes the host ports (base:livekitHostPorts) and tells clients the
public ones (base:livekitPublicPorts).
2. Bring-up
Each step ends with a check; do not continue past a failing one.
2.1 Workstation
cd bastion
npm run setup # pinned Pulumi CLI + generated Coolify SDK, repo-local (once)
cp .env.example .env.local # then fill it in (below)
npm test && npm run typecheck # sanity before touching prod
.env.local: COOLIFY_ENDPOINT, COOLIFY_TOKEN, PULUMI_CONFIG_PASSPHRASE (generate once, escrow
it now), BASTION_SSH_TARGET; for the first platform setup also INFISICAL_ADMIN_EMAIL and
INFISICAL_ADMIN_PASSWORD (choose once; the email needs no real mailbox). The scripts read this
file with their own loader because a Coolify token contains |: never source it.
Check: ./scripts/pulumi.sh version prints v3.277.0.
2.2 Stack and config
./scripts/pulumi.sh stack init prod # first time only
Set base:serverUuid, base:platformDomain, base:coolifyPublicUrl in Pulumi.prod.yaml
(src/config.ts documents every override). Prod also sets
base:livekitHostPorts {tcp:7883,udp:7884} and base:livekitPublicPorts {tcp:7885,udp:7886}.
Leave base:controlPlaneEnabled off for now.
Register the registry login (needed before the first image pull, so it belongs here and not in the control plane):
./scripts/pulumi.sh config set base:registry '{"registry":"ghcr.io","username":"<github-user>"}'
./scripts/pulumi.sh config set --secret base:registryToken '<classic PAT, read:packages>' # use openchamber_secret / a prompt, not shell history
Coolify environments are named after the stack (prod), never doubled
(fortspace-platform/prod, not …/prod-prod).
2.3 First up (base, control plane off)
./scripts/pulumi.sh preview --stack prod # read-only; read it
./scripts/pulumi.sh up --stack prod --yes --non-interactive
Expect it to stop once with the core database "core-postgres" runs without TLS. Coolify’s API
refuses the enable_ssl field, so the switch is manual:
Coolify UI → Servers → Databases → core-postgres → Enable SSL (this restarts the database).
Then re-run the same up. The stack reads the real TLS state from the Coolify API
(base:corePostgresTls, default required); every DSN follows it
(08). optional exists for a
throwaway pass only.
Check (eventual consistency, allow a few minutes): start actions return immediately and
Zitadel/Infisical restart until the bootstrap one-shot has created their databases.
ssh $BASTION_SSH_TARGET 'docker ps --format "{{.Names}}\t{{.Status}}" | sort' # all healthy, no restart loop
ssh $BASTION_SSH_TARGET 'docker logs $(docker ps -aqf name=core-postgres-bootstrap) 2>&1 | tail -3' # ends with "bootstrap done"
curl -s https://id.<domain>/.well-known/openid-configuration | jq -r .issuer # https://id.<domain>
curl -sI https://infisical.<domain> | head -1 # 200/302
2.4 Platform setup (workstation)
./scripts/platform-setup.sh prod
Runs control-plane/tools/prod (pnpm --filter @fortspace/prod-tools run setup — the bare
pnpm setup is a pnpm built-in that rejects --filter). It is idempotent. Since identity as code
(ADR-033) it does only what authenticates the stack:
- bootstraps the Infisical instance (admin from
.env.local, organization) and the project and folders for the first secrets (the stack adopts them); - creates the
platform-setupmachine user and key in Zitadel, proves the key works, then revokes the bootstrap PAT and deletes it from the volume (later runs need no ssh); - writes the workstation-owned secrets (
/platform/coolify,/platform/registry,/platform/pulumi); - sets
base:identityOrgsandbase:identityAuth(the secret goes through stdin) in the stack config.
Then npm run identity:imports (in bastion/), set base:identityEnabled, and pulumi up: the
stack creates the rest (the four Zitadel projects and their roles, the cockpit and rustfs-console
apps, cp-provisioner, the login policies (MFA forced), the Infisical
identities cp-worker / cp-broker and the platform secrets). The cockpit’s client secret and session
password need no config on a fresh install (the stack uses the secret of the app it created and a
generated password). --bootstrap is accepted and is the only mode: the former full setup (every
object through the APIs, the controlPlaneSecrets round trip) was removed once the stack owned those
objects, and --full is refused. Prod was set up the old way and adopted (below,
Adopt identity as code); a fresh install
along this path has not been run yet.
Check: the run ends without errors; Pulumi.prod.yaml gained identityOrgs and
identityAuth. In Infisical (https://infisical.<domain>, log in with the admin from
.env.local; switch the environment selector to prod, the UI opens on dev) project
fortspace-platform has its folders filled. tenant-bootstrap, routing/webhook-secrets and
registry are empty by design.
2.5 People
The seeded human is operator@fortspace.eu; its first password is the stack output
zitadel.initialAdminPassword. Log in at https://id.<domain> and register TOTP or a passkey
(mandatory).
For real people (create the user in the Zitadel console first, in the fortspace-platform org):
./scripts/superadmin.sh grant <email> # IAM_OWNER + cockpit operator + Fortspace Admin/superadmin
./scripts/superadmin.sh revoke <email>
Infisical is a manual step (its invite API refuses machine identities): invite the person as org admin (Organization → Access control), or remove them there on revoke. The script prints a reminder.
Check: the person can open https://cockpit.<domain> (redirects to Zitadel, comes back
logged in). Granting the rights decides what the person may do, not whether they reach the
app: Zitadel lets any account log into the cockpit (the login gate is off for Fortspace Cockpit,
ADR-032 amendment), and the cockpit itself answers a missing operator role with its page You
don’t have access (/auth/error?code=no_access), and an account of another org with
code=wrong_organization. Only the RustFS console (Fortspace Admin) is
still gated by Zitadel: without superadmin the login stops on Zitadel’s “Unknown error
occurred”. See Troubleshooting. Keep at least two superadmins.
Before you delete an old Zitadel project (the pre-ADR-032 Fortspace, or any project the stack
replaces): run ./scripts/superadmin.sh grant <email> for every human superadmin and check each can
open the cockpit and the RustFS console. Deleting a project drops every authorization on it, and neither
the setup (platform-setup.sh, bootstrap) nor the base stack grants a role to a human (only
superadmin.sh does): a person granted only on the old project loses the cockpit and the RustFS console.
2.6 Enable the control plane
- Pick the image tag: a
sha-<short>or a release version — neverlatest(it exists only after a release tag) and notedge(it moves on every push):./scripts/pulumi.sh config set base:controlPlaneTag sha-<short> ./scripts/pulumi.sh config set base:controlPlaneEnabled true./scripts/pulumi.sh up --stack prod --yes --non-interactive
The stack refuses to plan while any control-plane secret is missing, so the order cannot be
skipped. The same up turns the RustFS console on (https://storage.<domain>, OIDC-only).
Check:
curl -s https://api.<domain>/healthz # {"status":"ok"…}
curl -sI https://cockpit.<domain> | head -1 # 302 to the login
2.7 Optional: login in front of Mailpit
Mailpit’s UI holds every Zitadel/Infisical mail (login codes, invites, resets). Until a prod EU
SMTP relay exists, put the OIDC login in front of it (bastion/README.md, “Mailpit login”). Prerequisites: the traefikoidc plugin is registered in Coolify’s proxy
(--experimental.plugins.traefikoidc…, check with docker inspect coolify-proxy), and an OIDC
client in your external IdP with redirect URI https://mail.<domain>/oauth2/callback (and the
users allowed in that client’s group settings).
./scripts/pulumi.sh config set base:mailpitAuth '{"providerURL":"https://<idp>","allowedUsers":["a@x.eu","b@x.eu"]}'
./scripts/pulumi.sh config set --secret base:mailpitOidc '{"clientId":"…","clientSecret":"…","sessionEncryptionKey":"<openssl rand -hex 32>"}'
./scripts/pulumi.sh config set base:mailpitAuthEnabled true
./scripts/pulumi.sh up --stack prod --yes --non-interactive
Check: curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' https://mail.<domain>/ is a
302 to your IdP, and docker inspect <mailpit container> shows the traefikoidc labels with
no literal ${. Add a person later by editing allowedUsers and running up again.
2.8 Escrow and backup (do it now, not later)
- Offline: the Pulumi passphrase, Infisical
ENCRYPTION_KEY/AUTH_SECRET(./scripts/pulumi.sh stack output --show-secrets --stack prod), the Zitadel masterkey and the Zitadel session cookie secret (zitadel.sessionCookieSecret),INFISICAL_ADMIN_PASSWORD, the Coolify account, the Mailpit OIDC values. - The Pulumi state lives in the object storage bucket (versioned): versioning protects against a bad write, not against a lost account. Keep an encrypted copy of the bucket’s content off the account (and off the workstation).
- Commit
Pulumi.prod.yaml(ciphertext only) and push.
Database backup. There is no automated backup yet; take one by hand before any upgrade
(pg_dump -Fc per database from the core Postgres container, admin password = stack output
coreDbAdminPassword). Prod’s first one was taken on 2026-11-25 before the Zitadel upgrade, in
~/fortspace-backups/pre-upgrade-20261125-194842/ on the Coolify host: copy it off the host
and encrypt it — it holds the IdP’s user data and Infisical’s encrypted secrets.
2.9 Verification checklist
| Check | Expected |
|---|---|
docker ps on the host |
every platform container healthy, none restarting |
./scripts/pulumi.sh preview --stack prod |
no changes |
id. / api. / cockpit. / infisical. / storage. / mail. / livekit. over HTTPS |
valid certificate; the right redirect or 200 |
| Infisical log | SMTP - Verified connection to mailpit:1025 |
| Zitadel login as a superadmin | works, MFA prompted |
scripts/zitadel-login-check.sh (read only) |
instance default and every org: allowRegister=off ignoreUnknownUsernames=on, “MFA forced (…, no skip)”; no identity provider listed (or each declared in the stack); texts “ours already”; exit 0 |
| A real call through LiveKit (UDP 7886 → 7884) | not verified yet (needs go-meet through the broker) |
3. Operating it
The loop for any change
npm test && npm run typecheck
./scripts/pulumi.sh preview --stack prod --non-interactive # read the diff
./scripts/pulumi.sh up --stack prod --yes --non-interactive
# then verify on the host (labels, container health), not just "Pulumi said ok"
A changed compose or variable shows a *-start replacement: that is the restart trigger, not
a re-creation of the service.
| Task | How |
|---|---|
| Add/remove a Mailpit user | edit base:mailpitAuth.allowedUsers, up; also add them to the IdP client’s group |
| Reset a person’s lost second factor (phone lost, key broken) | verify who asks (out of band, e.g. their tenant admin by phone), then as a superadmin in the Zitadel console: the user → Authentication factors (TOTP, security keys) and Passkeys → remove the lost one (API: DELETE /v2/users/{id}/totp, /v2/users/{id}/u2f/{u2fId}, /v2/users/{id}/passkeys/{passkeyId}). MFA is forced, so the next login asks them to set up a new one; nothing else to do. Tenant admins cannot do it themselves (no Zitadel console rights) |
| Upgrade a component | override base:versions ({ zitadel: "v4.x" }), preview, dump the databases first (there is no automated backup yet: pg_dump per database from the core Postgres container, admin password = stack output coreDbAdminPassword), up |
| Upgrade Zitadel | as above, plus: the Login UI signs its session cookie since v4.19.2 (ZITADEL_SESSION_COOKIE_SECRET, the stack provides it), and every user signs in again — the old cookies carry no signature. Check docker logs for the migration and the ready probe |
| New control plane build | set base:controlPlaneTag, up |
| Re-run the Postgres bootstrap | bump base:bootstrapRevision |
| Re-run the platform setup | ./scripts/platform-setup.sh prod (idempotent, no ssh after the first run) |
| New superadmin / remove one | scripts/superadmin.sh grant <email> / revoke <email> |
| Read Mailpit mail with the login on | from the host: docker exec <mailpit container> wget -qO- http://localhost:8025/api/v1/messages (external curl is redirected to the IdP) |
| Rotate keys | LiveKit, Zitadel service keys, webhook secrets: 10. Coolify token and Pulumi passphrase rotation are not written yet |
| See or change the login policies | scripts/zitadel-login-check.sh (read only: the instance default, the platform org, every tenant org, whether each forces MFA, the texts, and what the stack would change; exit 2 if the apply would make the instance default’s MFA weaker (forced, local-only, setup skip, a factor dropped, a longer second- or multi-factor check lifetime) or remove something set by hand (an IdP on the instance or platform-org policy, customised instance texts); exit 3 if an org with its own policy does not force MFA. Other differences are printed, not judged). The instance and platform values live in src/identity/zitadel-login.ts / zitadel-access.ts, the tenant ones in the control plane’s saga (03) |
Guards you will hit on purpose: the program only names fortspace-platform and
fortspace-data-pool; Postgres, Redis, Zitadel, Infisical, RustFS and the control plane are
protect: true, so pulumi destroy refuses until you unprotect them.
Adopt identity as code (once, on the running platform)
Moves the objects inside Zitadel and Infisical that tools/prod created into the base stack’s
state, without recreating one of them (ADR-033). Steps 1 to 4 are read-only and can be repeated;
nothing in Zitadel, Infisical or Coolify changes before step 5. Which credential opens what is drawn in
03.
-
Back up the state. The bucket is versioned; also keep a file copy offline:
./scripts/pulumi.sh stack export --stack prod > prod-state-before.json(secrets stay encrypted with the passphrase). -
Collect two credentials, into your shell or the secret prompt, never into a chat or a ticket: the
platform-setupmachine key (Infisical: projectfortspace-platform, environmentprod,/platform/zitadel, secretSETUP_KEY_JSON) and the Infisical instance admin token (thetokenandorgIdfields ofcontrol-plane/tools/prod/.state/infisical-admin.json). -
Inventory.
ZITADEL_URL=https://id.<domain> INFISICAL_URL=https://infisical.<domain> INFISICAL_ORG_ID=… ZITADEL_KEY_JSON=… INFISICAL_TOKEN=… npm run identity:importsreads what exists (GET and search calls only, secret names never values) and prints the ids to adopt and what the stack would create. Set the two plain config values it prints (base:identityOrgs,base:identityImports), and the credentials as a secret, through stdin so they are not on a command line:printf '{"zitadelKeyJson":%s,"infisicalToken":"…"}' … | ./scripts/pulumi.sh config set --secret base:identityAuth --stack prod. Do not setbase:identityEnabledyet. -
Rehearse.
scripts/identity-rehearse-prod.sh(same two credentials in the environment, andBASTION_ENV_FILEpointing at your.env.local) previews the change on a copy of the state, in its own directory, with the real providers reading prod. It runspreviewonly. Expected on the current platform (read it against your own output; stop on anyERROR, anyMISMATCH, or aREVIEWline not listed here):Expected Zitadel 16 objects adopted, no update; 1 create: the new cp-provisionerkeyInfisical 38 adopted; 28 adoption fills (every folder and 13 secrets: the provider writes its own defaults, the real object does not change; one apply and they are gone); 2 creates (the client secrets of cp-worker,cp-broker); 1 real update:/platform/zitadel#PROVISIONER_KEY_JSONtakes the new keyCoolify exactly 2: control-plane-varsand thecontrol-plane-startrestart; every other resource unchangedParity the org ids, the four project ids and the cockpit and RustFS client ids equal what the control plane runs with today (12 of 12), and the RustFS audience too -
Apply. Set
base:identityEnabledtotrueinPulumi.prod.yaml, merge, and let the deploy workflow preview and apply (it first checks that the runner reaches both hosts), or do it by hand withpreviewthenup. The control plane restarts once: expect a short blip of the api, worker and cockpit. -
Verify. Log in to the cockpit and to the RustFS console, check the control plane’s health (
/healthz), and run./scripts/pulumi.sh preview --stack prod --expect-no-changes: the adoption fills must be gone. -
Revoke and clean up what Pulumi cannot. In Zitadel, delete the old
cp-provisionerkey (machine user → keys: keep only the newest). In Infisical, revoke the old universal-auth client secrets ofcp-workerandcp-broker(Access control → Identities → Universal Auth). Optionally delete the old copies of the Zitadel masterkey and operator password (/platform/zitadel) and of Infisical’s own keys (/platform/infisical), only after the offline escrow is confirmed (on prod they were left in place on purpose: they are no longer written or read by anything; delete the secrets only, never the folders, which the stack owns). Delete protection on the Infisical projects is not managed by the stack, and it can stay on: it was turned on forfortspace-platformandfortspace-brokerin the UI (2026-11-30) and a rehearsal with a refresh (REHEARSAL_REFRESH=1 REHEARSAL_IDENTITY=config scripts/identity-rehearsal.sh) on a copy of the prod state showed no drift and no planned change, so the stack does not switch it back off. Then trimbase:controlPlaneSecretstocockpit.COCKPIT_OIDC_CLIENT_SECRETandcockpit.SESSION_PASSWORD, and, after the next clean preview, removebase:identityImports.
Going back. Switching base:identityEnabled off is not a rollback: the program would no
longer declare the objects, and the plan would try to delete them (every one is protected, so Pulumi
refuses, and the adopted ones are also kept on delete). To return before step 7, restore the state
backup from step 1 and the previous Pulumi.prod.yaml; platform-setup.sh still works against the
same objects. After step 7 the old credentials no longer exist, so fix forward instead.
Disasters
| Lost | Consequence | Way back |
|---|---|---|
| The state bucket (or the account that owns it) | Pulumi forgets every resource | restore an off-account copy of the bucket. Without one: containers still run and hold their passwords, but the stack must be re-imported by hand — treat as a rebuild |
| The passphrase | state and Pulumi.prod.yaml secrets unreadable |
the escrow copy; there is no recovery otherwise |
| The GitHub Environment’s secrets | no automatic deploy | deploy by hand from a workstation: the state and the passphrase are in .env.local (4.3) |
| Zitadel unreachable / no superadmin | no human login | Break-glass |
Infisical ENCRYPTION_KEY |
every Infisical secret lost | escrow only |
4. State and deploys
4.1 Where the state lives
The base stack’s state is not in the platform it creates (the core Postgres and RustFS come out of the stack — a chicken-and-egg problem) and not on a workstation’s disk (one disk = one operator = one outage). It lives in a private object storage bucket, S3-compatible, in the EU:
| Bucket | s3://<bucket>/<prefix> — PULUMI_BACKEND_URL in bastion/.env.local |
| Provider | Scaleway Object Storage, region nl-ams (ADR-029). Any S3-compatible EU bucket works |
| Endpoint | AWS_ENDPOINT_URL=https://s3.nl-ams.scw.cloud (the AWS SDK resolves it) |
| Credentials | AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY, bucket-scoped. Two sets: one for operators, one for GitHub Actions |
| Encryption | unchanged: the passphrase secrets provider. The bucket holds the state, the passphrase decrypts the secrets in it |
| History | the bucket is versioned: a bad up can be rolled back to the previous checkpoint |
bastion/.state/ is the pre-migration snapshot (the file backend). scripts/pulumi.sh
refuses the prod stack on the file backend — that copy is a snapshot, and a second
writer would fork the state. BASTION_ALLOW_FILE_BACKEND=1 lifts the guard (recovery only).
4.2 Moving the state into the bucket
# .env.local: PULUMI_BACKEND_URL, AWS_REGION, AWS_ENDPOINT_URL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
./scripts/migrate-state.sh # backup, migrate, preview
The script takes a tarball of the local state into backup/pulumi-state/ of the workspace (BASTION_BACKUP_DIR overrides), runs
pulumi stack migrate (it re-encrypts the secrets for the target’s provider — the
passphrase stays, the salt changes) and ends with a preview that must show no changes.
Then commit the rewritten Pulumi.prod.yaml (ciphertext only).
4.3 The automatic deploy (merge → prod)
control-plane main ──push──▶ image.yml (build, test, push to GHCR)
│ workflow_run: success
▼
deploy-prod.yml (control-plane)
│ repository_dispatch: control-plane-deployed {tag}
▼
deploy-control-plane.yml (bastion)
│ set base:controlPlaneTag, preview, up, verify
▼
prod (api, worker, cockpit, migrate)
- The control plane publishes
sha-<short>on every push tomainand the semver tags on a release tag. The tag is what the base stack points at (base:controlPlaneTag). - The dispatch is sent by a GitHub App installed on the bastion repository only: the app’s token is minted in the control-plane workflow from the app’s private key. It can dispatch to bastion and nothing else.
- The bastion workflow runs in the
prodGitHub Environment (the secrets live there), checks the code (typecheck, tests), sets the tag, previews, applies the whole plan, verifies (/healthz, the image Coolify holds) and commits the tag bump tomain. One deploy at a time (concurrency: prod-deploy, never cancels a running one). - The whole plan is applied, not only the control plane: the stack is the only writer of the base infrastructure, and a partial apply would leave the state and the platform out of sync. A drift or an unapplied change in the base stack is therefore applied too — watch the preview in the run log.
- A push made by the workflow (
GITHUB_TOKEN) does not trigger other workflows: the tag bump is not re-checked by CI. It only touches the config file.
The second trigger: a merge on the bastion’s own main (ADR-030, amended). A change of
the stack with no new control-plane image deploys by itself too: the same workflow runs on
push to main, unless the commit only touches *.md, .env.example, .gitignore or
ci.yml. Differences from the dispatch:
- the tag is not touched: the one committed in
Pulumi.prod.yamlis applied and verified (the workflow reads it back withconfig get), and there is nothing to commit; - the workflow always checks out the latest
main, never the commit that triggered it, so a queued run cannot deploy an older tag than the one that is live; - there is no preview on a pull request: the prod secrets exist only in the
Environment, restricted to
main. The PR gets the typecheck and tests (ci.yml); the plan is in the run log after the merge, so review the diff ofsrc/with that in mind; - one pending run per queue: GitHub keeps a single pending run per concurrency group, so when a merge and a control-plane dispatch both wait behind a running deploy, the older one is dropped. A dropped dispatch does not deploy the new image: run the workflow by hand (Actions → deploy-control-plane → Run workflow) with the tag.
- a docs-only change does not deploy; to force a deploy, run the workflow by hand.
4.4 GitHub settings
bastion repository — Environment prod (secrets and variables):
| Name | Kind | Value |
|---|---|---|
COOLIFY_TOKEN |
secret | the Coolify API token (root team). It is root on the host |
PULUMI_CONFIG_PASSPHRASE |
secret | the passphrase that decrypts the state and the config |
AWS_SECRET_ACCESS_KEY |
secret | the CI key of the bucket |
COOLIFY_ENDPOINT |
variable | https://coolify.remis-lab.com |
PULUMI_BACKEND_URL |
variable | s3://<bucket>/<prefix> |
AWS_REGION |
variable | nl-ams |
AWS_ENDPOINT_URL |
variable | https://s3.nl-ams.scw.cloud |
AWS_ACCESS_KEY_ID |
variable | the CI key’s id |
Restrict the environment to the main branch and (recommended) require a reviewer: the
token above is root on the platform.
control-plane repository — secrets: BASTION_APP_CLIENT_ID (the GitHub App’s
Client ID, on the app’s settings page) and BASTION_APP_PRIVATE_KEY (the PEM it
generated). The App needs Contents: read and write on the bastion repository and nothing
else.
The bucket: versioning on, and a lifecycle rule that expires the non-current versions after ~90 days.
4.5 One-time setup (in this order)
- The bucket (Scaleway console → Object Storage): create a bucket in
nl-ams(e.g.fortspace-pulumi), turn versioning on, and a lifecycle rule that expires the non-current versions after ~90 days. Create two S3 access keys: one for the operators, one for GitHub Actions. Scaleway’s IAM scopes to a Project, not to a bucket: put the bucket in a dedicated Project (e.g.fortspace-state), create one IAM Application per consumer (pulumi-state-ci,pulumi-state-operators) with an API key each, and attach a policy scoped to that Project withObjectStorageBucketsRead,ObjectStorageObjectsRead,ObjectStorageObjectsWriteandObjectStorageObjectsDelete(noFullAccess, noBucketsWrite: Pulumi never creates the bucket). A bucket policy limited to the two applications (s3:ListBucket,s3:GetBucketLocation,s3:GetObject,s3:PutObject,s3:DeleteObject; nevers3:DeleteObjectVersionors3:PutBucketVersioning) is an optional extra. - The GitHub App (organization → Settings → Apps → New GitHub App):
Repository permissions: Contents: read and write, Metadata: read.
Install: only the
bastionrepository. Generate a private key and download the.pem. - The control-plane secrets:
BASTION_APP_CLIENT_ID(the app’s Client ID) andBASTION_APP_PRIVATE_KEY(the PEM). - The bastion
prodEnvironment: the secrets and variables of 4.4, restricted to themainbranch. - Move the state (4.2): put the bucket URL and the operator’s credentials in
bastion/.env.local, run./scripts/migrate-state.sh, commit the rewrittenPulumi.prod.yaml. - Test the chain: push a commit to the control plane’s
main(or re-run theimageworkflow withworkflow_dispatch) and watchFortSpace/bastion→ Actions.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
source .env.local fails, or scripts say “command not found” on the token |
the Coolify token has the shape 1, a pipe character, then hex; the shell reads the pipe as a pipeline |
never source it; scripts/env-file.sh is the loader every script already uses |
| Plan stops: core database runs without TLS | Coolify’s API refuses enable_ssl |
enable SSL in the Coolify UI (2.3), re-run |
| node clients (Infisical, control plane) fail with a certificate error | sslmode=require is a verified connection in node-postgres, Coolify’s CA is not trusted |
the stack already uses no-verify for node and require for libpq/pgx (psql, Zitadel, Pulumi CLI); do not hand-edit a DSN |
Zitadel rejects cannot parse 4070908800 |
Coolify parses compose as YAML 1.1: 2099-01-01T00:00:00Z becomes a timestamp, then an epoch |
the renderer quotes it (schema: yaml-1.1); never edit the compose in the Coolify UI |
| Two services answer on different hosts but neither is routed | Traefik router names are global: the same name with a different rule is a conflict that unroutes both | names carry the host slug (https-0-<id>-<host>); keep it when adding a service |
A router never matches, its rule shows a literal ${VAR} instead of the hostname |
Coolify does not interpolate ${VAR} in a label |
real hostnames in labels, always |
Router answers 503, Traefik logs invalid handler type: <nil> |
a plugin middleware (traefikoidc) received ${…} placeholders verbatim |
secrets for label-configured plugins must be baked into the compose (it is a secret in Pulumi); never Coolify variables |
| Changed a variable/compose, container unchanged | Coolify’s start on a running service is a no-op |
the stack uses restart; in the UI use Restart |
Bulk data is required |
an EnvsBulk with no variables |
a service with no variables gets none (the stack does this) |
| A removed variable is still in the container | deleting the Pulumi EnvsBulk does not delete the variables in Coolify |
DELETE /api/v1/services/<uuid>/envs/<var-uuid> (list with GET …/envs), then restart |
Image pull denied / 403 from GHCR |
no registry login on the host, a fine-grained PAT, or a tag that does not exist (latest before the first release) |
base:registry + base:registryToken (classic PAT, read:packages); pin sha-<short> |
pnpm setup complains about --filter |
setup is a pnpm built-in |
pnpm --filter @fortspace/prod-tools run setup (the script does) |
| Setup cannot read the Zitadel PAT | the Coolify API has no file read; the PAT is on the zitadel-bootstrap volume |
BASTION_SSH_TARGET must be set (first run only); the container is found by its router label |
| Calls: signaling works, no media | frp routes by port: the public pair is wrong, or livekit. resolves to an HTTP proxy instead of the VPS |
public TCP 7885 / UDP 7886 → host 7883 / 7884; livekit.<domain> straight to the VPS; clients get base:livekitPublicPorts |
| LiveKit webhooks never reach the control plane | wrong config shape | the webhook block uses urls: (a list), pointing at https://api.<domain>/internal/v1/livekit/webhook |
| Infisical UI looks empty | the environment selector opens on dev |
switch to prod; the secrets are there |
Infisical /organizations/<slug>/projects → 500 |
an Infisical bug: the URL segment must be the org UUID; a slug is cast as a UUID in SQL | use the UUID URL |
Cockpit: You don’t have access (/auth/error?code=no_access) after a successful Zitadel login |
the account has no operator role on Fortspace Cockpit; Zitadel no longer gates the project, the cockpit refuses |
superadmin.sh grant <email> (or add the authorization in the console) |
Cockpit: wrong organization (code=wrong_organization) |
the account belongs to another org than fortspace-platform (a tenant account): the cockpit checks the org like /admin/v1 |
use a platform account; a tenant account never gets in |
cp-cockpit exits at start: Invalid cockpit configuration: ZITADEL_PLATFORM_ORG_ID |
a cockpit image with the org check runs on a stack that does not supply the platform org id (deploy order) | apply the base stack with the variable (DEFAULT_CP_SECRET_NAMES.cockpit, supplied by identity as code); or roll the image tag back |
| RustFS console: Zitadel’s password page says “Unknown error occurred” | the user has no superadmin role on Fortspace Admin (Errors.User.GrantRequired, in Zitadel’s log only): that project keeps the login gate (RustFS cannot read roles) and login v2 cannot explain the refusal |
superadmin.sh grant <email> |
RustFS console: back from Zitadel, the console refuses the login (AccessDenied; RustFS logs Invalid audiences: <id> is not a trusted audience) |
Zitadel puts the Fortspace Admin project id in aud and RustFS does not trust it: RUSTFS_IDENTITY_OPENID_OTHER_AUDIENCES is empty or names another project (the project was re-created, or base:rustfsOidc.projectId is stale without identity as code) |
with identity as code the stack sets it from the project; otherwise correct base:rustfsOidc.projectId and apply (03) |
storage.<domain> shows no OIDC login (the console is off) |
the RustFS console is enabled only with a client id and secret (base:rustfsOidc; with identity as code the secret is the config value or the secret of the app the stack created) |
set the secret and apply; the root key is never a login |
After an OIDC app was deactivated (or deleted) in Zitadel, the cockpit shows Your session has ended (code=session_expired), meet users are sent to log in again, and the new login does not come back |
Zitadel answers a refresh for a deactivated app with 400 invalid_client (no active client not found): the cockpit ends the session on invalid_client, go-meet on any 400/401 from a refresh. A new login names a client Zitadel no longer accepts, so it ends on Zitadel’s side, not on our error page (that page was not recorded on login v2) |
reactivate the app (Zitadel console → project → app), or let the next deploy restore it if the stack owns it (cockpit, rustfs-console); a tenant’s meet-<slug> app is restored by re-running its provisioning. Zitadel may take a moment to see a reactivation (no active client not found once more) |
| The cockpit or a tenant’s meet login suddenly stops on “Unknown error occurred” | the login gate is back: the role check (authorizationRequired) on Fortspace Cockpit / Workspace, or the org check on Fortspace Cockpit (changed by hand in the console, or an old setup tool). The org check on Workspace is on by design and only stops an org without a grant |
the next deploy’s preview shows the drift (projectRoleCheck/hasProjectCheck); apply, or fix it in the console to match bastion/src/identity/zitadel-projects.ts |
| A tenant user sees Zitadel’s “Register” page, or “User not found in the system” | the tenant org has no policy of its own and the instance default allows registration (a tenant provisioned before W6, or the instance policy changed by hand) | scripts/zitadel-login-check.sh shows which org inherits what and how; the next deploy restores the instance default (an org that inherits it is then fine); an org with its own policy that allows registration is fixed by hand as in the next row (a provisioning retry does not revisit an ACTIVE tenant) |
| After a password, a person lands on “Set up 2-Factor” with no Skip | expected: MFA is forced and they have no second factor yet | they set up an authenticator app or a security key; a passkey login needs no second factor |
| A tenant user logs in without being asked for a second factor | their org has its own policy that does not force MFA (made by hand, or before Q2), or they logged in with a passkey (multi-factor by itself) | scripts/zitadel-login-check.sh (exit 3 names the org). The saga does not fix it: a retry only resumes a failed provisioning and skips the steps that succeeded. Fix by hand, as a superadmin: reset the org’s policy to the instance default: DELETE /management/v1/policies/login with header x-zitadel-orgid: <org id> (verified on dev v4.20.6; the console’s reset of the org’s login settings does the same): the org then inherits MFA forced and no registration, and only loses its own default redirect (the cockpit instead of its meet host). Or edit the org’s policy to the saga’s rule (forceMfa on, forceMfaLocalOnly off, MFA init skip 0, registration off, unknown usernames hidden, default redirect https://meet.<slug>.<domain>/). Run the check again: exit 0 |
| The deploy removed an identity provider from the login screen | the base stack declares no IdP on the instance or platform login policy, and the provider detaches every one it does not declare | declare the IdP in the stack (idps of the policy) and deploy; until then attach it again by hand. scripts/zitadel-login-check.sh exits 2 when an apply would remove one |
| Everybody, even with the right password, gets “Sign-in failed. Check your password…” on a tenant login | ignoreUnknownUsernames on: a wrong password, an unknown, foreign, deactivated or locked account all get that one message (on purpose) |
check the user in the Zitadel console (state, org, lockout); Zitadel’s log names the cause |
| A login ends on “You are signed in” with no button | the org’s policy has no defaultRedirectUri (an org created by hand, or before W6), or the login app still serves its cache (15 min) |
give the org its own policy (provisioning), or wait / restart the login container |
| Tenant login pages show Zitadel’s own texts, the cockpit’s show ours | expected: Zitadel v4.20.6 does not pass instance texts on to an org (upstream bug); decided to wait for the fix, not to set texts per org (Q-20) | none |
| Mailpit: You are not allowed to access this service (IdP page) | the IdP client restricts allowed user groups and the user is not in one | add the user to the group, or clear the list (allowedUsers still filters) |
| Mailpit: 403 from Traefik after the IdP login | the IdP’s email is not in allowedUsers |
add it exactly as the IdP sends it |
pulumi destroy refuses |
protect: true by design |
unprotect deliberately, never as a reflex |
Stack shows an environment prod-prod |
environment named after project + stack | environments are named after the stack only |
pulumi stack output of a secret prints [secret] |
needs --show-secrets |
only in a private terminal; never paste output into a chat or a ticket |
| The prod stack cannot run on the local file backend | the guard in scripts/pulumi.sh: the live state is in the bucket |
set PULUMI_BACKEND_URL and the AWS credentials; BASTION_ALLOW_FILE_BACKEND=1 only to read the snapshot |
AccessDenied / SignatureDoesNotMatch on the bucket |
wrong endpoint, region or key for the provider | AWS_ENDPOINT_URL=https://s3.nl-ams.scw.cloud, AWS_REGION=nl-ams, the provider’s own S3 keys (not the IAM ones) |
| the state looks empty — wrong bucket, wrong prefix or a fresh project? | the workflow refuses to stack init: an empty stack would plan the creation of the whole platform |
check PULUMI_BACKEND_URL (bucket and prefix) against the operator’s .env.local |
| The deploy workflow finds no secret | the workflow runs in the prod Environment: a pending environment (reviewer not approved) means no secrets |
approve the environment, or deploy by hand from a workstation |
The control plane does not run <tag> |
the image is not in GHCR (the build failed) or the tag is wrong (sha- + the first 7 characters of the commit) |
check the image workflow of that commit; the tag is in the deploy-prod log |
A script that sets PULUMI_BACKEND_URL still writes to the bucket |
scripts/pulumi.sh loads its env file over the environment, and .env.local carries PULUMI_BACKEND_URL and AWS_*: a backend set by the caller is silently replaced by the live one (this wrote a stray stack into the bucket once) |
give pulumi.sh an env file without those keys (the rehearsal does) and check pulumi whoami -v shows the backend you meant before the first write |
| The deploy stops at UNREACHABLE: Zitadel (or Infisical) | with identity as code on, the providers reach id.<domain> and infisical.<domain> from the runner; the check retries for about a minute |
check the host answers (/debug/ready, /api/status) and the DNS/proxy path from outside; the run is safe to repeat |
| After adopting, the preview shows an update on every folder and on most secrets | the adoption fill: the provider writes its own defaults (an empty secret reminder, forceDelete) into an imported state |
expected once; one apply and the next preview and a refresh are clean |
| the stack did not converge after the deploy (warning on the last step) | a second preview still finds changes: drift made by hand in Zitadel or Infisical, or a resource that does not settle | read that preview; fix the drift or the code, the deploy itself succeeded |
Open items
- Prod LiveKit media path (UDP 7886 → 7884) and a real call are not verified.
- The Pulumi state moved to an object storage bucket (ADR-029), but the backup of the bucket is still a manual copy, and there is still no automated backup of the core Postgres (10).
- The automatic deploy applies the whole plan, not only the control plane: a drift in
the base stack is deployed too. A reviewer on the
prodEnvironment is the cheap mitigation, not yet configured. superadmin.shshould report humans that lack theFortspace Cockpitgrant (todo in the project knowledge); since the login gate is off for the cockpit, such a person sees the cockpit’s no access page rather than a Zitadel dead end.- Mailpit goes away with the prod EU SMTP relay (ADR-023); its login and this section go with it.
- Identity as code (ADR-033) is applied on prod (adopted 2026-11-30). The setup is bootstrap-only
(the Infisical instance bootstrap, the
platform-setupuser and key, the first PAT, the workstation-owned secrets,base:identityAuth); it is unit-tested but has not been run against a fresh instance. - The Infisical projects’ delete protection is turned on in the UI, not by the stack.