Deploy architecture — submodule-driven DEV, coordinated promotion to staging & PROD
Brouillon : cette page n'a pas encore été relue et peut être incomplète ou inexacte.
This describes how the dowonou-deploy superrepo and its four app submodules
build, deploy, and promote across environments.
Principles
Section intitulée « Principles »- Build once, deploy many. Each app version is built exactly once. The same immutable image flows DEV → staging → PROD with no rebuild — except the two frontends, which bake env config at build time and are therefore rebuilt per environment (see Frontend exception).
- Superrepo is the source of truth. An app never deploys itself directly. On merge it builds, pushes, and bumps the superrepo; the superrepo bump is the deploy trigger.
- Per-environment manifests decouple environments. DEV can advance automatically while staging and PROD stay pinned to a reviewed set.
- Cluster credentials live only in the superrepo, scoped per environment via GitHub Environments. App repos hold only a DOCR push token and the GitHub App.
- Argo-ready. The superrepo deploy job is the only thing a future ArgoCD migration replaces; nothing upstream changes.
The four apps
Section intitulée « The four apps »| Chart key (manifest) | Submodule (repo) | Default branch | DOCR image | Type |
|---|---|---|---|---|
ged-backend |
ged_backend (Django) |
main |
agbale-ged-backend |
backend |
ged-frontend |
agbale_frontend (Vue) |
main |
agbale-ged-frontend |
frontend |
afcm-backend |
afcm-backend (PHP) |
master |
afcm-backend |
backend |
afcm-frontend |
afcm-front (Vue) |
master |
afcm-frontend |
frontend |
The three names per app (chart key / submodule / image) differ — the manifest records all of them so app CI and Helm agree.
Version manifests
Section intitulée « Version manifests »environments/{dev,staging,prod}/versions.yaml is the desired state per env:
registry: registry.digitalocean.com/afcorpapps: ged-backend: { submodule: ged_backend, image: agbale-ged-backend, type: backend, sha: 766b592, tag: "766b592" } ...sha— the submodule short SHA = the gitlink this manifest tracks. The canonical pin.tag— the literal image tag the deploy job sets on the chart.- backend:
tag == sha(immutable, promoted unchanged). - frontend:
tag == sha-<env>(rebuilt per env;shais still the pin). - An empty
tagis skipped by the deploy job (logged) — used to seed an environment that has no version yet (e.g. PROD on day one).
- backend:
Flow per app, on merge to its default branch
Section intitulée « Flow per app, on merge to its default branch »App repo .github/workflows/deploy-dev.yml:
- Build the Docker image; tag = short SHA (frontends:
sha-dev). doctl registry login; push the tag to DOCR. Tags are immutable — the workflow refuses to overwrite an existing tag.- Mint a token from the shared GitHub App, clone the superrepo, and in a
fetch/reset/retry loop (race-safe against concurrent merges) atomically:
- advance this app’s gitlink (
git update-index --cacheinfo 160000,<sha>,<path>), and - set this app’s
sha+taginenvironments/dev/versions.yaml, then commit and push tomain.
- advance this app’s gitlink (
- The push changes
environments/dev/**, which triggers the superrepodeploy.ymlto helm-upgrade DEV only.
merge ─► build+push image ─► bump superrepo (dev manifest + gitlink) ─► deploy.yml (DEV) ─► helm upgradeDeploy (superrepo deploy.yml)
Section intitulée « Deploy (superrepo deploy.yml) »- Triggered by
pushtomainunderenvironments/<env>/**. Theplanjob maps changed paths → environments, so DEV moving never touches staging/PROD. - Runs as the matching GitHub Environment (
dev/staging/production) so the correct cluster secret and protection rules apply. - Pure helm. Reads the target manifest, sets
<chartkey>.image.tagper app, and runsdeploy/scripts/helm-deploy.sh <env>(theagbale-platformumbrella chart). No build, no app-source checkout. Idempotent (helm upgrade --install). workflow_dispatchremains as a manual redeploy-current-pins escape hatch.
Promotion (superrepo promote.yml)
Section intitulée « Promotion (superrepo promote.yml) »workflow_dispatch(from_env, to_env, apps) opens a PR that copies pins forward:
- Backends:
tag = shacopied as-is — identical image, no rebuild. - Frontends: dispatches the app repo’s
build-env.ymlto buildsha-<to_env>, waits for it, then pins that tag.
Merging the PR triggers deploy.yml for the target environment.
dev → stagingandstaging → prodonly (no skipping, no backwards).- Staging/PROD manifest paths are gated by
CODEOWNERS; theproductionEnvironment adds required reviewers on the deploy itself (two gates for PROD).
Frontend exception (why frontends rebuild)
Section intitulée « Frontend exception (why frontends rebuild) »Both Vue Dockerfiles compile VITE_API_URL, VITE_KEYCLOAK_*, VITE_BASE_PATH
into the static bundle at build time, with the host derived from the target
environment. A “dev” frontend image has dev.dowonou.com baked in and cannot
be promoted to PROD unchanged. So frontends are rebuilt per env (deterministically,
from the same submodule SHA) and tagged sha-<env>. Backends read config at
runtime and are true build-once artifacts.
Future option: refactor the frontends to read a runtime-served
/config.js(nginxenvsubstat container start) instead of bakedVITE_vars. That would make frontends true build-once artifacts and remove this exception — and is the natural prerequisite for a clean ArgoCD (Phase 2) migration.
Versioning & rollback
Section intitulée « Versioning & rollback »- The image tag is the submodule short SHA (backends) or
sha-<env>(frontends) — always traceable to a commit. - The set of pins in a manifest is the environment’s release. Roll back by
reverting the manifest commit (or re-running
deploy.ymlon a prior pin). - A future superrepo git tag over a validated set of manifests is a coherent, reproducible full-stack version and a one-revert rollback unit.
Access model (summary — full setup in deploy-setup.md)
Section intitulée « Access model (summary — full setup in deploy-setup.md) »- App teams: write to their own submodule repo only (PR into protected branches).
- The cross-repo bump runs as a GitHub App (not a personal PAT), scoped to Contents RW on the app repos + superrepo. It can advance DEV without review; staging/PROD are CODEOWNERS-gated so it cannot land them unreviewed.
- Cluster creds: superrepo GitHub Environment secrets only. App-triggered pipelines physically cannot reach staging/PROD clusters.
Phase 2 (out of scope here): ArgoCD
Section intitulée « Phase 2 (out of scope here): ArgoCD »The layout is Argo-shaped: per-env manifests, image-tag pins, no build in the
deploy path. Phase 2 replaces only the superrepo deploy.yml helm job with an
Argo Application per environment pointed at environments/<env>/. App CI,
manifests, and promotion are unchanged.