| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- # Test image for running backend and frontend tests
- # syntax=docker/dockerfile:1.7
- FROM python:3.13-slim AS backend-test
- WORKDIR /app
- # Install system dependencies for testing
- # procps: pkill, which a camera test uses to clean up its fake ffmpeg.
- RUN apt-get update && apt-get install -y --no-install-recommends \
- curl \
- procps \
- && rm -rf /var/lib/apt/lists/*
- # Install Python dependencies including test dependencies.
- # BuildKit cache mount makes subsequent builds re-use the pip download
- # cache so the second build only does install work — the slow ~60-90s
- # fetch step from the first build becomes ~5s. Requires DOCKER_BUILDKIT=1
- # (already set in test_docker.sh).
- COPY requirements.txt requirements.lock ./
- COPY requirements-dev.txt ./
- # Two installs, as in CI: the lock pins the newest ruff (requirements.txt only
- # has a floor) and requirements-dev.txt pins the one CI enforces, so a single
- # install would have two exact pins for ruff and fail. The second one wins.
- RUN --mount=type=cache,target=/root/.cache/pip \
- pip install -r requirements.lock && pip install -r requirements-dev.txt
- # Copy backend code
- COPY backend/ ./backend/
- COPY pyproject.toml ./
- # 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
- # Test image runs pytest and exits — there is no long-running service
- # to probe. HEALTHCHECK NONE is the documented Docker opt-out and
- # silences Trivy DS-0026 without adding meaningless probe logic.
- HEALTHCHECK NONE
- # Default command runs pytest (excluding docker integration tests).
- # -v dropped: 5300+ "PASSED foo::bar" lines per worker eat noticeable
- # stdout I/O time and clutter test_docker.sh output. --tb=short still
- # gives full failure tracebacks when something breaks.
- # -n 30: the test host's worker count. Not -n auto (with psutil installed
- # that counts physical cores only, 16) nor -n logical (the Docker host's 32
- # CPUs, more than this machine is meant to use).
- CMD ["pytest", "backend/tests/", "--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"]
|