From 76f579b0138ca5216541352c7c2f3d9eb8f6ed4d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 23 Oct 2026 23:18:58 +0000 Subject: [PATCH 1/2] =?UTF-8?q?fix(dashboard):=20add=20public/.gitkeep=20?= =?UTF-8?q?=E2=80=94=20directory=20was=20missing=20in=20git?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- dashboard/public/.gitkeep | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 dashboard/public/.gitkeep diff --git a/dashboard/public/.gitkeep b/dashboard/public/.gitkeep new file mode 100644 index 0000000..fe2113f --- /dev/null +++ b/dashboard/public/.gitkeep @@ -0,0 +1,3 @@ +# Static assets directory +# Files placed here are served at the root path of the dashboard. +# Currently empty — Next.js App Router doesn't require any static assets. -- 2.49.1 From a3b1fa0250e87839ccfd10c44db69af9d63c469a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 23 Oct 2026 23:20:47 +0000 Subject: [PATCH 2/2] =?UTF-8?q?chore(dashboard):=20add=20validate-build.sh?= =?UTF-8?q?=20=E2=80=94=20pre-push=20build=20sanity=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- dashboard/validate-build.sh | 187 ++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100755 dashboard/validate-build.sh diff --git a/dashboard/validate-build.sh b/dashboard/validate-build.sh new file mode 100755 index 0000000..81e29af --- /dev/null +++ b/dashboard/validate-build.sh @@ -0,0 +1,187 @@ +#!/bin/bash +# Simulates a fresh `git clone` + `docker build` of the dashboard image, +# WITHOUT requiring docker. Catches: +# - COPY failures (file missing in build context) +# - npm ci / build failures +# - Standalone output sanity +# +# Run BEFORE pushing — catches the kind of issues we hit in PR #1/#2/#3 +# where the build worked locally but failed on prod because a file was +# missing from git. +# +# Usage: bash dashboard/validate-build.sh # from repo root +# or: bash validate-build.sh # from dashboard/ +# or: bash /path/to/validate-build.sh /path/to/GPU-Node + +set -eu + +# Auto-detect repo root: parent of this script's directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO="${1:-$(dirname "$SCRIPT_DIR")}" +DASH="$REPO/dashboard" + +if [ ! -d "$DASH" ]; then + echo "ERROR: dashboard dir not found at $DASH" + echo "Usage: $0 [path/to/GPU-Node]" + exit 1 +fi + +if ! command -v git >/dev/null 2>&1; then + echo "ERROR: git is required" + exit 1 +fi + +if ! command -v npm >/dev/null 2>&1; then + echo "ERROR: npm is required" + exit 1 +fi + +TMP=$(mktemp -d) +CTX="$TMP/build-context" +mkdir -p "$CTX" + +echo "==> [1/5] Listing git-tracked files in dashboard/" +cd "$REPO" +TRACKED=$(git ls-files dashboard/) +echo " $(echo "$TRACKED" | wc -l) files tracked" + +echo "==> [2/5] Simulating docker build context (git-tracked files only)" +for f in $TRACKED; do + rel="${f#dashboard/}" + dest="$CTX/$rel" + mkdir -p "$(dirname "$dest")" + cp "$f" "$dest" +done + +# Apply .dockerignore: remove files matching patterns +echo "==> [3/5] Applying .dockerignore patterns" +cd "$CTX" +if [ -f .dockerignore ]; then + # Read patterns, skip comments + while IFS= read -r line; do + line="${line%%#*}" + line="$(echo "$line" | xargs)" + [ -z "$line" ] && continue + # Skip patterns that point outside (like ../.git) + case "$line" in + ../*) continue ;; + esac + # Use find to delete matches + find . -name "$line" -type f -delete 2>/dev/null || true + find . -name "$line" -type d -exec rm -rf {} + 2>/dev/null || true + done < .dockerignore +fi + +echo "==> [4/5] Build context contents:" +find . -type f | sort | head -30 +echo " ..." +echo " total: $(find . -type f | wc -l) files" + +echo "==> [5/5] Running npm ci + npm run build on build context" +mkdir -p "$TMP/build" +cp -r "$CTX/." "$TMP/build/" +cd "$TMP/build" + +# Simulate what the Dockerfile does: +# Step 4: COPY package.json package-lock.json ./ (already done above) +# Step 4: RUN npm ci --no-audit --no-fund +# Step 5: RUN touch next-env.d.ts +# Step 6: COPY tsconfig.json next.config.ts postcss.config.mjs .eslintrc.json ./ +# Step 7: COPY src ./src +# Step 8: COPY public ./public +# Step 9: RUN npm run build +# +# Validate each COPY source actually exists in build context BEFORE running +# npm ci (so we fail fast on missing files). + +echo "==> [5/5] Simulating Dockerfile COPY + RUN steps" +cd "$TMP/build" + +# Parse COPY commands from Dockerfile and verify each source exists +echo " Validating COPY sources exist in build context..." +MISSING=0 +while IFS= read -r line; do + # Skip comments and blank lines + case "$line" in + \#*) continue ;; + "") continue ;; + esac + # Only handle plain COPY (skip COPY --from=... multi-stage copies) + case "$line" in + "COPY "--from*) continue ;; + COPY*) : ;; + *) continue ;; + esac + # Strip "COPY " prefix + rest="${line#COPY}" + # Trim leading/trailing whitespace + rest="$(echo "$rest" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + # Split into tokens: last is destination, rest are sources + set -- $rest + if [ "$#" -lt 2 ]; then continue; fi + # Last arg is destination + n=$# + dst="${!n}" + # Sources are args 1..n-1 + i=1 + while [ "$i" -lt "$n" ]; do + src="${!i}" + i=$((i + 1)) + # Skip wildcards for simplicity (we already listed all files) + case "$src" in + *\**) continue ;; + esac + if [ ! -e "$src" ]; then + echo " ✗ COPY source missing: $src (line: $line)" + MISSING=$((MISSING + 1)) + else + echo " ✓ COPY source present: $src" + fi + done +done < Dockerfile + +if [ $MISSING -gt 0 ]; then + echo + echo "==> ✗ $MISSING COPY source(s) missing in build context" + echo " These will cause \`docker build\` to fail with:" + echo " COPY failed: file not found in build context or excluded by .dockerignore" + exit 1 +fi + +echo +echo " All COPY sources present. Running npm ci + npm run build..." + +# Step 5: RUN touch next-env.d.ts +touch next-env.d.ts + +# Step 4: npm ci --no-audit --no-fund +npm ci --no-audit --no-fund 2>&1 | tail -5 + +# Step 8: RUN npm run build +echo +echo "==> Running npm run build..." +if npm run build 2>&1 | tail -40; then + echo + echo "==> ✓ Build succeeded" + if [ -f .next/standalone/server.js ]; then + echo "==> ✓ Standalone output present" + ls -la .next/standalone/server.js + else + echo "==> ✗ Standalone output MISSING" + exit 1 + fi + if [ -d .next/static ]; then + echo "==> ✓ Static assets present" + else + echo "==> ✗ Static assets MISSING" + exit 1 + fi +else + echo "==> ✗ BUILD FAILED" + exit 1 +fi + +echo +echo "==> Cleanup: $TMP (kept for inspection)" +echo " Build context: $CTX" +echo " Build dir: $TMP/build" -- 2.49.1