mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 03:01:21 +02:00
Dockerfile.test only COPYed backend/ and pyproject.toml, so the integration test at tests/integration/test_gcode_viewer.py:63 silently pytest.skip'd in every Docker run with "gcode_viewer/ index.html not present at /app/gcode_viewer/index.html". That was deliberate fallback behaviour for unit-test environments where the assets are intentionally absent, but in CI it meant the #1218 packaging regression (3D Preview returning {"detail":"Not Found"} because the embedded PrettyGCode viewer wasn't bundled into the prod image) had no test guarding against a recurrence — the test that was supposed to catch it was the one being skipped. Add COPY gcode_viewer/ ./gcode_viewer/ to the backend-test stage, matching the path the production Dockerfile uses (static_dir.parent / "gcode_viewer" = /app/gcode_viewer/) so the assertion runs against the same layout the app sees at runtime. Path-anchored comment in the Dockerfile so a future maintainer doesn't strip the COPY as unused.
52 lines
1.5 KiB
Docker
52 lines
1.5 KiB
Docker
# Test image for running backend and frontend tests
|
|
FROM python:3.13-slim AS backend-test
|
|
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies for testing
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Python dependencies including test dependencies
|
|
COPY requirements.txt ./
|
|
COPY requirements-dev.txt ./
|
|
RUN pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
|
|
|
|
# Copy backend code
|
|
COPY backend/ ./backend/
|
|
COPY pyproject.toml ./
|
|
|
|
# Embedded GCode viewer assets — required so the @app.get("/gcode-viewer/...")
|
|
# packaging-regression test in tests/integration/test_gcode_viewer.py actually
|
|
# runs instead of pytest-skipping with "index.html not present". Path matches
|
|
# the production Dockerfile (static_dir.parent / "gcode_viewer" = /app/gcode_viewer/).
|
|
COPY gcode_viewer/ ./gcode_viewer/
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /app/data /app/logs /app/archive
|
|
|
|
# Environment variables for testing
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV DATA_DIR=/app/data
|
|
ENV TESTING=1
|
|
|
|
# Default command runs pytest (excluding docker integration tests)
|
|
CMD ["pytest", "backend/tests/", "-v", "--tb=short", "-p", "no:cacheprovider", "-n", "30"]
|
|
|
|
# -------------------------------------------
|
|
# Frontend test stage
|
|
FROM node:22-bookworm-slim AS frontend-test
|
|
|
|
WORKDIR /app/frontend
|
|
|
|
# Copy package files and install
|
|
COPY frontend/package*.json ./
|
|
RUN npm ci
|
|
|
|
# Copy frontend source
|
|
COPY frontend/ ./
|
|
|
|
# Default command runs tests
|
|
CMD ["npm", "test", "--", "--run"]
|