Secrets
Infisical is the source of every secret, GitHub only holds the key to read it.
Secrets live in the self hosted Infisical on The Keep (secrets.findmalek.engineer, see the keep). .env.example stays the documented list of keys, Infisical holds the values. Containers never talk to Infisical: the deploy scripts read it once and hand the result to Dokploy.
Flow
- A deploy job (
staging,release) or a preview logs in to Infisical with Universal Auth (INFISICAL_CLIENT_IDandINFISICAL_CLIENT_SECRET) and exports the environment as dotenv. - The script merges, from weakest to strongest: what Dokploy already holds, the Infisical export, the values it computes (public urls,
DEPLOY_ENV,SEED,MESSAGING_LIVE,ALLOW_PREVIEW_ORIGINS,S3_PREFIX; for previews also the database url and the demo password). - The merged env is written to the Dokploy compose service (
compose.update) and the service is deployed.
Without the four INFISICAL_* settings nothing changes: staging and production keep the env Dokploy already has and previews keep using the PREVIEW_APP_ENV secret. Values are never printed, the job summary only shows the number of keys.
Environments
| Infisical env | Used by |
|---|---|
dev | pnpm dev:secrets on a laptop |
staging | the staging workflow, every merge to main |
prod | the release workflow, published release |
preview | every PR preview, shared by all PRs (the per PR database, urls and passwords are computed) |
Previews, staging and dev must only hold log-only or test provider keys, they never send real messages.
Locally
Install the Infisical cli, run infisical login (set INFISICAL_API_URL=https://secrets.findmalek.engineer/api), then infisical init once to fill .infisical.json. pnpm dev:secrets runs turbo dev with the dev environment. pnpm dev still reads the root .env. pnpm secrets:pull dev .env.infisical writes an environment to a file (needs the INFISICAL_* variables).
Add a key
- Declare it in
packages/env/src/api.ts(ornext.ts) and add it to.env.examplewith a comment.pnpm env:checkruns in CI and fails when a key is in.env.examplebut not declared inpackages/env. - Add the value to each Infisical environment that needs it. Run the
secrets-diffworkflow (Actions, run workflow) to list, per environment, the keys of.env.examplethat Infisical lacks, names only. - Redeploy: staging on the next merge, production on the next release, or run the
stagingworkflow by hand.
Keys the deploy scripts compute (urls, DEPLOY_ENV, SEED, ...) are not stored in Infisical, the list is COMPUTED in scripts/env-keys.mjs. POSTGRES_PASSWORD must be stored in staging and prod: it has to stay stable because the database volume keeps the first one.
Rotate
- Change the value in Infisical for the environment.
- Redeploy that environment. For
BETTER_AUTH_SECRETall sessions end, forPOSTGRES_PASSWORDchange the role password in the database first. - Machine identity: create a new client secret in Infisical, update the GitHub secret
INFISICAL_CLIENT_SECRET, then revoke the old one.
What stays in GitHub
- secrets:
INFISICAL_CLIENT_ID,INFISICAL_CLIENT_SECRET, plus the credentials of the deploy target itself (DOKPLOY_TOKEN) andGITHUB_TOKEN - variables:
INFISICAL_URL,INFISICAL_PROJECT_ID, the Dokploy ids and public urls (see deploy runbook)
Everything the apps read at runtime (database, auth, providers, storage, analytics keys) moves to Infisical. PREVIEW_APP_ENV and any other app secret in GitHub can be deleted once the preview environment is filled.