Previews

What a pull request preview contains, what it reuses from staging, and what it costs.

Every non draft pull request from this repo gets a preview on The Keep, deployed by .github/workflows/preview.yml through the Dokploy api. One sticky comment on the PR lists everything. Closing the PR deletes it all (preview-cleanup.yml).

What gets built

turbo ls --affected decides which apps changed against the base branch (a change in a shared package counts for every app that uses it).

What changedDeployed for the PREverything else
nothing in the appsnothingthe comment links to staging
only web, dashboard or docsjust those apps, pointed at the staging apilinked to staging
api (or a shared package it uses)own postgres, api, web and dashboard, and docs if it changeddocs linked to staging

Hostnames are pr-<N>-<app>.preview-ritorno.findmalek.engineer, staging apps are staging-ritorno, app-staging-ritorno, api-staging-ritorno and docs-staging-ritorno on findmalek.engineer.

What a PR with an api change gets

  • its own postgres container (database ritorno), removed when the PR closes
  • SEED=demo, MESSAGING_LIVE=false (log only, nothing is ever sent), DEPLOY_ENV=pr-<N> so storage keys live under the pr-<N>/ prefix and OpenObserve traces go to the stream pr-<N>
  • demo logins: the comment shows the hotel owner owner.dar-zitouna@demo.ritorno.test and the super admin email, never the password (see signing in)
  • the database host for WhoDB, one shared container. The postgres host is internal, only WhoDB (same Dokploy network) can reach it
  • links to OpenObserve, Umami and GlitchTip only when OPENOBSERVE_PUBLIC_URL, UMAMI_URL (with UMAMI_API_TOKEN) or GLITCHTIP_URL (with GLITCHTIP_API_TOKEN) are set in the repo, otherwise nothing is shown

The tradeoff

Reusing staging is cheaper and faster (no build, no database) but not isolated.

  • a frontend only PR shares the staging database with every other such PR. Sign ups, edits and test data from one PR show in the others
  • the preview frontend talks to the staging api from another origin. The staging api needs ALLOW_PREVIEW_ORIGINS=true, which trusts *.preview-ritorno.findmalek.engineer and *.findmalek.engineer for sign in. Never set it in production
  • sign in redirects built by the api use the staging dashboard url, so after login you may land on staging instead of the preview. Open the preview url again, the session cookie belongs to the preview origin
  • a PR that changes the api gets full isolation, so put the api change and the frontend change in the same PR when you need to test them together
  • WhoDB can reach every database on the Dokploy network if you know its host and password, so it must only be reachable on the tailnet, never on a public domain

Signing in

The repo is public, so the PR comment and the job summary never hold a password. Every password of a preview is derived from DOKPLOY_TOKEN, the PR number and PREVIEW_SECRET_VERSION in .github/scripts/preview-lib.mjs. A maintainer with the token computes them locally:

DOKPLOY_TOKEN=... pnpm preview:creds 123

It prints the password shared by the demo owner and the super admin, and the postgres password to enter in WhoDB with the host from the comment.

Older comments printed the passwords. Each preview run edits its sticky comment, but GitHub keeps the edit history, so treat those values as leaked. Bumping PREVIEW_SECRET_VERSION rotates every derived secret: the next run of an open PR sets new passwords and recreates its postgres (demo data only). Bump it again whenever a derived value leaks.

Needed in the repo

Variables DOKPLOY_URL, PREVIEW_DOMAIN, DOKPLOY_ENVIRONMENT_ID and secret DOKPLOY_TOKEN. Optional secret PREVIEW_APP_ENV (extra env lines for every preview, for example the S3_* keys of a bucket) and the observability variables above. Without the required ones the job exits green with a note.

CI cache

ci.yml caches .turbo/cache and .next/cache through GitHub Actions. The Docker builds accept TURBO_API and TURBO_TEAM build args plus a turbo_token secret for a remote cache. A self hosted cache on The Keep is the next step, see the keep.

On this page