fix(docker): generate optimized maps during frontend image build - #193
fix(docker): generate optimized maps during frontend image build#193mohamed-khairy-5i wants to merge 2 commits into
Conversation
The frontend Docker image was built without the optimized world maps (frontend/public/maps_optimized is gitignored and generated from server/mapas_source via the server's export-frontend-maps script). A clean clone + docker build produced a frontend that 404s on /maps_optimized/mapa_*.json and never renders the world. - frontend/Dockerfile: new multi-stage 'maps' stage runs the server's export script from server/mapas_source before the Next build; build context is now the repo root - frontend/scripts/check-maps.mjs + prebuild: local builds fail loudly with the exact command to run when the maps are missing - compose files + CI: build context moved to repo root; CI generates maps before the frontend build - README: documents the manual map-generation step Closes Bitcoindefi#19
Addresses the Gitar review finding: the guards only checked for >=1 map file, so an interrupted export (e.g. 3 of 294 maps) would pass and still ship a frontend that 404s for most of the world. - check-maps.mjs: compares present map ids against the mapa_* dirs in server/mapas_source and fails listing how many are missing - Dockerfile maps stage: guard now requires one output per source map Verified locally: complete set exits 0; partial set (3/294) and empty dir both exit 1 with the exact command to run.
Code Review ✅ Approved 1 resolved / 1 findingsGenerates optimized frontend maps during the Docker image build and updates build contexts to the repository root, addressing the maps guard only checks for >=1 file, not full set finding. No issues found. ✅ 1 resolved✅ Edge Case: Maps guard only checks for ≥1 file, not full set
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Important Your trial ends in 5 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more. Was this helpful? React with 👍 / 👎 | Gitar |
Summary
Closes #19 — the frontend Docker image was built without the optimized world maps, so a clean clone +
docker buildproduced a frontend that 404s on/maps_optimized/mapa_*.jsonand never renders the world.frontend/public/maps_optimized/is gitignored and generated fromserver/mapas_source/via the server'sexport-frontend-mapsscript, butfrontend/Dockerfilenever ran that step beforepnpm build.Changes
frontend/Dockerfile— new multi-stagemapsstage: installs server deps, copiesmapNpcStorage.ts+exportFrontendOptimizedMaps.ts+mapas_source/, runs the export, thenCOPY --from=mapsintopublic/maps_optimizedbefore the Next build. Build context is now the repo root.frontend/scripts/check-maps.mjs+prebuildhook — local builds now fail loudly with the exact command to run when the maps are missing, instead of silently producing a broken bundle.frontend/docker-compose*.yml— build context moved to repo root (context: ..,dockerfile: frontend/Dockerfile)..github/workflows/ci.yml— frontend job installs server deps and generates the maps before building; docker-build job uses repo root as context.README.md— documents the manual map-generation step..dockerignore(repo root) — keeps the new root build context small.Acceptance criteria
server/mapas_source/during the image build.prebuildrunscheck-maps.mjs, which exits 1 with instructions (cd server && pnpm export-frontend-maps).Verification (run locally)
pnpm export-frontend-maps→ 294 maps exported (mapa_1.json…mapa_506.json).node scripts/check-maps.mjs→ exit 0 with maps present; exit 1 with a clear message when the folder is missing/empty.pnpm run lint→ 0 errors (2 pre-existing warnings, untouched).pnpm exec tsc --noEmit→ clean.pnpm run build→ all routes compile.Note: I could not run the Docker image build itself (no Docker daemon in my environment), but the export script it invokes is verified end-to-end, and the CI
docker-buildjob will exercise the full image build.