image builds: reset repo to HEAD before stamping the app build

The pi-gen and Debian Live chroot hooks run `npm install`, which rewrites
the tracked app/package-lock.json, then build_app.sh stamps
build/.build-stamp from that dirty working tree.  On first boot repair.sh
runs `git reset --hard` (reverting the lock) *before* it recomputes the
stamp, so the baked stamp can never match -- and the device rebuilds the
React app every time, the exact OOM-prone step baking the build in (#536)
was meant to avoid.

Verified against WROLPi-v0.27.2: the shipped image had `M app/package-lock.json`,
baked stamp a9c6ef61..., post-reset stamp 2b908c6c... (guaranteed mismatch).

Mirror repair.sh in both image hooks: `git reset --hard HEAD` right after
npm install and before build_app.sh, so the baked stamp represents committed
source and matches what the device recomputes.  Only the lock is reverted;
build/, node_modules, and the venvs are untracked and survive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roland 2026-07-18 13:37:00 -06:00 • committed by lrnselfreliance
parent 4cafb9f00e
commit 575d2f9744
2 changed files with 19 additions and 0 deletions

View file

@ -56,6 +56,16 @@ npm --version
node --version
npm install
# `npm install` rewrites the tracked app/package-lock.json. build_app.sh (below)
# stamps build/.build-stamp from that working tree, but on-device repair.sh runs
# `git reset --hard` before it stamps -- reverting the lock -- so a stamp baked
# against the dirty lock can never match on first boot and the box rebuilds the app.
# Reset to HEAD here, exactly as repair.sh does, so the baked stamp represents
# committed source. Only the lock is reverted; build/, node_modules, and the venvs
# are untracked and survive. The repo is cloned and reset as root (same owner),
# so no safe.directory config is needed here.
git -C /opt/wrolpi reset --hard HEAD
# Build the React production bundle. Without this, /opt/wrolpi/app/build/
# does not exist and wrolpi-app.service (`serve build -l 3000 ...`) returns
# 404 for every request. Baking the build into the squashfs means the

View file

@ -63,6 +63,15 @@ echo "Controller pre-installed"
# Install webapp.
(cd /opt/wrolpi/app && npm install)
# `npm install` rewrites the tracked app/package-lock.json. build_app.sh (below)
# stamps build/.build-stamp from that working tree, but on-device repair.sh runs
# `git reset --hard` before it stamps -- reverting the lock -- so a stamp baked
# against the dirty lock can never match on first boot and the Pi rebuilds the app
# (the exact OOM-prone step this bake-in avoids). Reset to HEAD here, exactly as
# repair.sh does, so the baked stamp represents committed source. Only the lock is
# reverted; build/, node_modules, and the venvs are untracked and survive.
git -C /opt/wrolpi reset --hard HEAD
# Build the React production bundle now, so it is baked into the image. Without
# this the Pi would build on first boot -- a multi-minute, memory-hungry step
# that can OOM on a 2GB Pi. build_app.sh stamps the output so the on-device