Migrate codeforafrica builds to Docker Bake - #1512
Merged
Merged
Conversation
koechkevin
approved these changes
Aug 25, 2026
Matches the naming already used by roboshield/trustlab/climatemappedafrica/ charterafrica.
Adds docker/apps/codeforafrica/Dockerfile and a bake target following the climatemappedafrica/charterafrica/roboshield/trustlab pattern: turbo-prune based multi-stage build, secrets mounted via BuildKit instead of build args, and CI wired through the shared _bake-and-push.yml reusable workflow. Unlike charterafrica, codeforafrica deploys to real DEV and PROD Dokku apps today, so this preserves the pre-bake pipeline's DEV/PROD split exactly: each environment gets its own build (matching roboshield's precedent, since codeforafrica bakes an environment-specific NEXT_PUBLIC_APP_URL into the client bundle) and its own Mongo secret (CODEFORAFRICA_MONGO_URL for DEV, with the Dokku app name appended per the pre-bake workflow's convention; CODEFORAFRICA_MONGODB_URL for PROD, already a full connection string). The DockerHub repository name (codeforafrica/codeforafrica-ui) is preserved as well, since the live Dokku apps already pull images by that exact name. NEXT_PUBLIC_APP_NAME and NEXT_PUBLIC_APP_LOGO_URL are public config values that happen to be stored as GitHub Secrets already; they're passed through as bake --set overrides from _build-codeforafrica.yml rather than modifying the shared _bake-and-push.yml, keeping this app-specific quirk contained. PROD's NEXT_PUBLIC_APP_URL is left pointing at the same (unusual, .dev.) domain the pre-bake PROD workflow already used — not a regression, and not this migration's job to fix.
kelvinkipruto
force-pushed
the
feat/codeforafrica-docker-bake
branch
from
August 25, 2026 17:39
7dd2443 to
014bd1e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Migrate
codeforafricafrom the legacy shared rootDockerfileto the repository's per-app Dockerfile and Docker Bake build architecture, following the same pattern already established forcharterafrica/climatemappedafrica/pesayetu/roboshield/techlabblog/trustlab.Why
Docker builds against the legacy shared
Dockerfileare slow and have repeatedly broken in ways unrelated to the app itself (see #1507, #1509). Movingcodeforafricaonto the turbo-prune-based Bake architecture keeps its build isolated, cacheable, and consistent with the other migrated apps.codeforafricauses a custom Express + Payload server (server.ts, compiled todist/server.js) that connects to MongoDB viapayload.init()beforenext buildruns, so — likeclimatemappedafrica/charterafrica— this build genuinely needs a reachable database, not just a well-formed connection string.Unlike
charterafrica,codeforafricadeploys to real DEV and PROD Dokku apps today, so this migration is deliberately conservative about preserving exact existing behavior rather than cleaning anything up:codeforafrica/codeforafrica-ui(notcodeforafrica/codeforafrica, the naming every other migrated app uses) because the live Dokku apps already pull images by that exact name.roboshield's precedent —codeforafricabakes an environment-specificNEXT_PUBLIC_APP_URLinto the client bundle, so a single build-once-promote wouldn't work.CODEFORAFRICA_MONGO_URLwith the Dokku app name appended (/codeforafrica-ui), matching the pre-bake DEV workflow's own string concatenation. PROD uses a different secret,CODEFORAFRICA_MONGODB_URL, already a full connection string with no appending. These are two distinct GitHub Secrets in the pre-bake workflows today — this PR does not merge or rename them, just moves the same two references into the new pipeline.NEXT_PUBLIC_APP_URLis left ashttps://cfa.dev.codeforafrica.org— yes, a.dev.domain for the production build — because that's what the pre-bake PROD workflow already bakes in. Whether that's a bug is a separate, pre-existing question outside this migration's scope.What changed
codeforafrica Docker Bake migration
docker/apps/codeforafrica/Dockerfile. Likeclimatemappedafrica/charterafrica, this app doesn't use Next.jsoutput: "standalone", so the runner stage copies the fullnode_modules/.nextfolder rather than a pruned standalone bundle, plusmigrations/.codeforafricatarget todocker-bake.hcland the sharedappsgroup, inheriting_payload-app-runnerdirectly — its secret names (PAYLOAD_SECRET, and nowDATABASE_URL) already match the shared convention, so no app-specific secret list is needed (unlikecharterafrica).NEXT_PUBLIC_APP_NAMEandNEXT_PUBLIC_APP_LOGO_URLare public config values that happen to already be stored as GitHub Secrets; they're passed through as bake--setoverrides from_build-codeforafrica.ymlrather than touching the shared_bake-and-push.yml.DATABASE_URLfor the Payload DB connection instead ofMONGODB_URL, matching the other migrated apps, inpayload.config.ts.ui-builder-base/ui-runner-baseimages in CI.make codeforafricaand Compose usage to the Bake-built image.codeforafricamigrated indocker/README.md.Dockerfilestage andcodeforafrica-deploy-*.ymlworkflows untouched for now, matching the rollback-safety precedent from the other migrations — to be disabled once this pipeline is validated in production.CI/CD
_build-codeforafrica.yml) and a new orchestration workflow (codeforafrica.yml): DEV builds and deploys on every push (real Dokku app atui-1.dev.codeforafrica.org), PROD builds and deploys only on apackage.jsonversion bump (real Dokku app atui-2.prod.codeforafrica.org) — mirroringroboshield's two-build DEV/PROD split.codeforafricato thepr-build.ymlimage-validation workflow andscripts/pr-build-targets.mjs's target detection. PR builds use the realCODEFORAFRICA_MONGO_URLsecret (mapped toDATABASE_URL, same DEV-style app-name suffix) rather than a dummy value, since the build needs a reachable database to succeed.CODEFORAFRICA_MONGO_URL/CODEFORAFRICA_MONGODB_URL/CODEFORAFRICA_PAYLOAD_SECRET/CODEFORAFRICA_SENTRY_PROJECT/NEXT_PUBLIC_CODEFORAFRICA_APP_NAME/NEXT_PUBLIC_CODEFORAFRICA_APP_LOGO_URLcarry over, just remapped to the Bake secret names.Validation
docker buildx bake codeforafricaagainst a real local MongoDB instance — fullturbo prune→ install →next build(compile, lint, static export) →payload buildall pass.docker runsmoke test — the built image boots, Payload connects, Next.js starts, and both/and/adminreturn HTTP 200.pnpm test:scripts— allpr-build-targetsdetection tests pass, including the updatedcodeforafricacases.Type of change
Screenshots
N/A
Checklist