Simulates a fresh git clone + docker build of the dashboard image,
WITHOUT requiring docker. Reproduces the exact failure mode that bit us
in PR #1/#2/#3 (file present locally but missing from git, so build
worked in dev but failed on prod after `git pull`).
What it does:
1. Lists git-tracked files in `dashboard/`
2. Creates a temp build context containing ONLY those files (simulates
what `docker build` actually sees on a fresh clone)
3. Applies `.dockerignore` patterns
4. Parses `Dockerfile` COPY commands and verifies each source exists
in the build context (fails fast if anything is missing)
5. Runs `npm ci --no-audit --no-fund`
6. Runs `npm run build`
7. Verifies `.next/standalone/server.js` and `.next/static/` exist
Usage:
bash dashboard/validate-build.sh # from repo root
bash validate-build.sh # from dashboard/
bash /path/to/validate-build.sh /path/to/repo
Catches: missing files in COPY, missing public/, missing next-env.d.ts
(though the Dockerfile now creates that one on the fly), and any
TypeScript/Next.js build errors.
Run this BEFORE pushing any dashboard change.
The Dockerfile has `COPY public ./public`, but `public/` directory was
never committed to git (empty directories are not tracked by git without
a placeholder file).
On a fresh checkout (after `git pull` on prod), `public/` didn't exist,
causing:
Step 8/24 : COPY public ./public
COPY failed: file not found in build context or excluded by .dockerignore:
stat public: file does not exist
Fix: added `dashboard/public/.gitkeep` so the directory is tracked.
Discovered via the new build-context validator script
(`scripts/validate-dashboard-build.sh`) which simulates a fresh git
checkout + docker build.