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>
32 lines
1.2 KiB
Docker
32 lines
1.2 KiB
Docker
FROM python:3.12-slim
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1
|
|
|
|
WORKDIR /app
|
|
|
|
RUN pip install --no-cache-dir pipenv
|
|
|
|
COPY Pipfile Pipfile.lock ./
|
|
RUN pipenv install --system --deploy
|
|
|
|
COPY src ./src
|
|
COPY lib ./lib
|
|
RUN mkdir -p src/static/bundled-lib && cp -f lib/*.py src/static/bundled-lib/
|
|
COPY workspace ./workspace
|
|
# 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 \
|
|
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
|
|
|
|
CMD ["uvicorn", "app:app", "--app-dir", "src", "--host", "0.0.0.0", "--port", "8080"]
|