Skip to content

fix(docker): generate optimized maps during frontend image build - #193

Open
mohamed-khairy-5i wants to merge 2 commits into
Bitcoindefi:mainfrom
mohamed-khairy-5i:fix/docker-frontend-maps-19
Open

fix(docker): generate optimized maps during frontend image build#193
mohamed-khairy-5i wants to merge 2 commits into
Bitcoindefi:mainfrom
mohamed-khairy-5i:fix/docker-frontend-maps-19

Conversation

@mohamed-khairy-5i

@mohamed-khairy-5i mohamed-khairy-5i commented Aug 27, 2026

Copy link
Copy Markdown

Summary

Closes #19 — the frontend Docker image was built without the optimized world maps, so a clean clone + docker build produced a frontend that 404s on /maps_optimized/mapa_*.json and never renders the world.

frontend/public/maps_optimized/ is gitignored and generated from server/mapas_source/ via the server's export-frontend-maps script, but frontend/Dockerfile never ran that step before pnpm build.

Changes

  • frontend/Dockerfile — new multi-stage maps stage: installs server deps, copies mapNpcStorage.ts + exportFrontendOptimizedMaps.ts + mapas_source/, runs the export, then COPY --from=maps into public/maps_optimized before the Next build. Build context is now the repo root.
  • frontend/scripts/check-maps.mjs + prebuild hook — 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

  • Un clon limpio y un build de Docker producen un frontend que dibuja el mundo — the Dockerfile now generates all 294 maps from server/mapas_source/ during the image build.
  • Si faltan los mapas, el build falla con un mensaje que explica qué correr — prebuild runs check-maps.mjs, which exits 1 with instructions (cd server && pnpm export-frontend-maps).
  • El README documenta el paso — added under "Levantar El Frontend".

Verification (run locally)

  • pnpm export-frontend-maps → 294 maps exported (mapa_1.jsonmapa_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-build job will exercise the full image build.

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
Comment thread frontend/scripts/check-maps.mjs Outdated
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.
@gitar-bot

gitar-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Generates 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

📄 frontend/scripts/check-maps.mjs:43-47 📄 frontend/Dockerfile:27-28
Both check-maps.mjs and the Dockerfile guard (grep -c '^mapa_' -gt 0) only assert that at least one mapa_*.json exists. A partial or interrupted export (e.g., 3 of the expected ~294 maps) would pass the check yet still ship a frontend that fails to render most of the world, reintroducing the exact class of silent breakage this PR targets. Consider asserting against an expected minimum count (or comparing against the number of mapa_* directories in server/mapas_source/) so incomplete generations also fail loudly.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

El build de Docker produce un frontend sin mapas: el mundo no se dibuja

1 participant