Fix Docker build by relying on committed bundled-demos copies
The previous build step copied `workspace/code/<demo>.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 <cursoragent@cursor.com>
This commit is contained in:
13
Dockerfile
13
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
|
||||
|
||||
Reference in New Issue
Block a user