From b8d62e01d9c8e0cb68840f48b84c60e57f07e381 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sun, 10 May 2026 06:44:53 +1200 Subject: [PATCH] Fix Docker build by relying on committed bundled-demos copies The previous build step copied `workspace/code/.py` into `src/static/bundled-demos/` at image-build time. That failed for some build contexts where `workspace/` wasn't materialised when the RUN ran (cp: cannot stat ... No such file or directory). Since `src/static/bundled-demos/*.py` are version-controlled and ship with `COPY src ./src`, the runtime image already has them. Replace the fragile cp loop with a `diff -q` invariant that fails the build if a canonical demo drifted between `workspace/code/` and `src/static/bundled-demos/`, catching mismatches at build time instead of runtime. Co-authored-by: Cursor --- Dockerfile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4421f68..c8a1215 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,12 +15,15 @@ COPY src ./src COPY lib ./lib RUN mkdir -p src/static/bundled-lib && cp -f lib/*.py src/static/bundled-lib/ COPY workspace ./workspace -# Mirror canonical demo files into the static bundle so the editor's -# "Reset demos" button works from a static-only host too. -RUN mkdir -p src/static/bundled-demos && \ - for f in pattern_rainbow_demo.py pattern_twinkle_demo.py pattern_chase_demo.py \ +# Sanity-check: the canonical demos under `src/static/bundled-demos/` (used by +# the editor's "Reset demos" button) must stay in sync with `workspace/code/`. +# Files in `bundled-demos/` are committed to git and copied via `COPY src` +# above; this step just fails the build if a checked-in copy drifted from the +# canonical version, so the mismatch is caught here instead of at runtime. +RUN for f in pattern_rainbow_demo.py pattern_twinkle_demo.py pattern_chase_demo.py \ adc_slider_demo.py pin_demo.py serial_demo.py; do \ - cp -f "workspace/code/$f" "src/static/bundled-demos/$f"; \ + diff -q "workspace/code/$f" "src/static/bundled-demos/$f" \ + || { echo "ERROR: $f out of sync between workspace/code/ and src/static/bundled-demos/" >&2; exit 1; }; \ done EXPOSE 8080