Aller au contenu

Ephemeral environments

Brouillon : cette page n'a pas encore été relue et peut être incomplète ou inexacte.

Two flavours of throwaway environment live in this repo. Pick by what you’re testing.

App preview Full-platform ephemeral
Workflow preview-deploy.yml / preview-teardown.yml ephemeral-deploy.yml / ephemeral-teardown.yml
Triggered by a PR on an app repo (label preview) a PR on this superrepo (label ephemeral)
Deploys ONE app pair (the PR’s frontend + that app’s dev backend) the WHOLE stack: portal /, GED /ged, AFCM /afcm
Chart used superrepo chart from main the chart on the PR
Images the app repo builds its own this workflow builds all four from the PR’s submodule commits
Host pr-<N>-<slug>.dev.dowonou.com eph-<N>.dev.dowonou.com
Use it for iterating on one app cross-app behaviour: the portal chooser, shared-realm SSO, ingress/routing changes, chart changes

Both reuse dev’s Keycloak/MinIO and are removed automatically.

  1. Open a PR on this superrepo whose submodule gitlinks point at the branches/commits you want to preview together (bump the submodule you’re testing; leave the others at dev).
  2. Add the ephemeral label. Optionally add clone-ged-data to seed the isolated GED DB from dev’s documents (otherwise GED starts empty).
  3. The workflow comments the URL (https://eph-<N>.dev.dowonou.com/) when ready (~10 min: it builds four images).
  4. New commits to the PR redeploy. Remove the ephemeral label or close the PR to tear it down.

Manual trigger: Actions → Ephemeral environment deploy → Run workflow with the PR number.

  • Full stack, PR’s chart. The deploy runs from the superrepo checkout, so chart changes on the PR (ingress, portal, subcharts) are exercised. values-ephemeral.yaml turns the whole platform on; values-dev.yaml underneath supplies the (test) secrets and service config.
  • Images built from submodule commits. Frontends are baked with the ephemeral host (VITE_* → https://eph-<N>.dev.dowonou.com/...) but Keycloak stays on dev (VITE_KEYCLOAK_URL=https://dev.dowonou.com/auth) — the realm session is dev’s. Build args mirror each app’s build-env.yml; if an app changes its args, update this workflow too.
  • GED database is isolated. The GED backend runs migrate on startup, so it must never touch shared dev. The env gets its own in-namespace Postgres (ephemeral, no PVC); clone-ged-data restores a read-only pg_dump of dev’s agbale_ged_db into it and lets the backend migrate on top — a faithful rehearsal of a real dev GED-backend upgrade.
  • AFCM database is isolated too. AFCM gets its own afcm_db on the same in-namespace Postgres (its initdb creates agbale_ged_db and afcm_db). The AFCM migration Job runs migrate and db:seed against that fresh database, so SSO-provisioned users and any AFCM writes never reach dev’s afcm_db. The seed is required, not cosmetic: AFCM resolves a user’s company from the Keycloak realm (resolveCompanyForRealm) and fails closed when no company maps to that realm, so an unseeded afcm_db means SSO can provision nobody. It is gated behind an explicit afcm-backend.migrations.seed flag precisely so it can never be switched on against a shared database.
  • Keycloak redirect URIs. The deploy registers https://eph-<N>.dev.dowonou.com/* on both afcm-client and agbale-ged — one wildcard covers each app’s OAuth callback and its /…/silent-check-sso.html page. Teardown removes them. Serialized via the ephemeral-kc concurrency group.
  • AFCM chat. Reverb runs inside the env (<release>-afcm-reverb, wss://eph-<N>.dev.dowonou.com/afcm/ws) with the app credentials in values-ephemeral.yaml; the workflow bakes that file’s public key into afcm-frontend. Attachments go to dev’s MinIO, bucket afcm-files, prefix ephemeral-chat/ (not cleaned on teardown). See messaging.md.
  • TLS/DNS are automatic. *.dev.dowonou.com resolves to the ingress LB, and cert-manager (letsencrypt-prod) issues a per-host cert. No manual steps.
  • Always pass --set global.domain=<host>. The chart names the TLS cert <domain>-tls; omitting the override makes the release try to adopt dev’s dev.dowonou.com cert and the upgrade fails with an ownership error. (For the same reason, never helm upgrade --reuse-values with a -f values-dev.yaml that resets global.domain.)
  • Frontend↔backend must be compatible. Deploying a new frontend against an older backend surfaces as subtle bugs, not errors — e.g. a frontend calling /api/me/ against a backend that predates that endpoint (404 → blank user), or an RBAC-menu frontend against a backend without the KC→RBAC sync (empty menu). Point both submodules at compatible commits.
  • pg_dump version must be ≥ the server. Dev’s Postgres is v18 → the clone Job uses postgres:18-alpine. A v15 client aborts with a “server version mismatch”.
  • Never migrate or seed a shared DB from an ephemeral env. Both GED and AFCM run against the in-namespace Postgres for exactly this reason. afcm-backend.migrations.seed must stay false anywhere the database is shared.
  • Subcharts are vendored as .tgz and committed. helm/agbale-platform/charts/*.tgz is what actually renders — no workflow runs helm dependency update. Editing helm/charts/<app>/ alone changes nothing at deploy time; you must re-run helm package helm/charts/<app> -d helm/agbale-platform/charts/ and commit the rebuilt tarball.
  • Same host ⇒ first-party cookies. Silent SSO works because KC (/auth) and the apps share dev.dowonou.com; the hidden-iframe KC session cookie isn’t third-party-blocked.
  • Keycloak is still dev’s, so realm-level changes (mappers, groups, clients) are not exercised by an ephemeral env — --import-realm only seeds a realm that does not yet exist. Apply them to the live realm with deploy/scripts/apply-realm-mappers.sh.
  • Images build sequentially (~10 min). A build matrix would parallelize.
  • The Keycloak redirect RMW is serialized among ephemeral runs, but a concurrent app-preview on the same client is a rare unguarded race; re-run the affected deploy if a redirect goes missing.