fix(dashboard): public/ missing in git + add build validator #4

Merged
mikan merged 2 commits from fix/dashboard-public-missing into master 2026-10-23 23:23:32 +00:00
Collaborator

What broke

Dockerfile has COPY public ./public, but the public/ directory was never committed to git (empty directories aren't tracked without a placeholder).

After git pull on prod:

Step 8/24 : COPY public ./public
COPY failed: file not found in build context or excluded by .dockerignore:
stat public: file does not exist

Why my previous "build passes locally" claims were wrong

I was developing in /home/z/my-project/GPU-Node/ — a working tree where I had run next dev / next build locally, which auto-created public/ and next-env.d.ts. So npm run build worked locally but failed on prod where the only files present were the ones actually tracked in git.

This is the same root cause as PR #3 (next-env.d.ts missing): files that exist in my dev tree but not in git.

Fix

1. dashboard/public/.gitkeep

Added placeholder so the public/ directory is tracked.

2. dashboard/validate-build.sh

A new pre-push validator script that simulates a fresh git clone + docker build without requiring docker. Reproduces the exact failure mode (file present locally, missing from git) so we catch it before pushing.

What it does:

  1. Lists git-tracked files in dashboard/
  2. Creates a temp build context with only those files (matches what docker build actually sees on a fresh clone)
  3. Applies .dockerignore patterns
  4. Parses Dockerfile COPY commands, verifies each source exists in 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

Run this BEFORE pushing any dashboard change. Catches:

  • Missing files in COPY (next-env.d.ts, public/, eslintrc, etc.)
  • TypeScript / Next.js build errors
  • Standalone output issues

Verification

Validator output on this branch:

✓ COPY source present: package.json
✓ COPY source present: package-lock.json
✓ COPY source present: tsconfig.json
✓ COPY source present: next.config.ts
✓ COPY source present: postcss.config.mjs
✓ COPY source present: .eslintrc.json
✓ COPY source present: src
✓ COPY source present: public       <-- was ✗ before this PR
✓ Build succeeded
✓ Standalone output present
✓ Static assets present

Files changed

  • dashboard/public/.gitkeep — new (placeholder)
  • dashboard/validate-build.sh — new (validator script)

Lesson learned

I should have run validate-build.sh (or done an actual git clone + docker build) before every PR. Going forward I'll run it before pushing.

## What broke Dockerfile has `COPY public ./public`, but the `public/` directory was never committed to git (empty directories aren't tracked without a placeholder). After `git pull` on prod: ``` Step 8/24 : COPY public ./public COPY failed: file not found in build context or excluded by .dockerignore: stat public: file does not exist ``` ## Why my previous "build passes locally" claims were wrong I was developing in `/home/z/my-project/GPU-Node/` — a working tree where I had run `next dev` / `next build` locally, which auto-created `public/` and `next-env.d.ts`. So `npm run build` worked locally but failed on prod where the only files present were the ones actually tracked in git. This is the same root cause as PR #3 (`next-env.d.ts` missing): files that exist in my dev tree but not in git. ## Fix ### 1. `dashboard/public/.gitkeep` Added placeholder so the `public/` directory is tracked. ### 2. `dashboard/validate-build.sh` A new pre-push validator script that simulates a fresh `git clone + docker build` **without requiring docker**. Reproduces the exact failure mode (file present locally, missing from git) so we catch it before pushing. What it does: 1. Lists git-tracked files in `dashboard/` 2. Creates a temp build context with **only** those files (matches what `docker build` actually sees on a fresh clone) 3. Applies `.dockerignore` patterns 4. Parses `Dockerfile` COPY commands, verifies each source exists in 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: ```sh bash dashboard/validate-build.sh # from repo root bash validate-build.sh # from dashboard/ bash /path/to/validate-build.sh /path/to/repo ``` Run this BEFORE pushing any dashboard change. Catches: - Missing files in COPY (next-env.d.ts, public/, eslintrc, etc.) - TypeScript / Next.js build errors - Standalone output issues ## Verification Validator output on this branch: ``` ✓ COPY source present: package.json ✓ COPY source present: package-lock.json ✓ COPY source present: tsconfig.json ✓ COPY source present: next.config.ts ✓ COPY source present: postcss.config.mjs ✓ COPY source present: .eslintrc.json ✓ COPY source present: src ✓ COPY source present: public <-- was ✗ before this PR ✓ Build succeeded ✓ Standalone output present ✓ Static assets present ``` ## Files changed - `dashboard/public/.gitkeep` — new (placeholder) - `dashboard/validate-build.sh` — new (validator script) ## Lesson learned I should have run `validate-build.sh` (or done an actual `git clone` + `docker build`) before every PR. Going forward I'll run it before pushing.
super-z-bot added 2 commits 2026-10-23 23:21:39 +00:00
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.
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.
mikan merged commit 05c7eeca87 into master 2026-10-23 23:23:32 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mikan/GPU-Node#4