Dockerfile.test 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Test image for running backend and frontend tests
  2. FROM python:3.13-slim AS backend-test
  3. WORKDIR /app
  4. # Install system dependencies for testing
  5. RUN apt-get update && apt-get install -y --no-install-recommends \
  6. curl \
  7. && rm -rf /var/lib/apt/lists/*
  8. # Install Python dependencies including test dependencies
  9. COPY requirements.txt ./
  10. COPY requirements-dev.txt ./
  11. RUN pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
  12. # Copy backend code
  13. COPY backend/ ./backend/
  14. COPY pyproject.toml ./
  15. # Embedded GCode viewer assets — required so the @app.get("/gcode-viewer/...")
  16. # packaging-regression test in tests/integration/test_gcode_viewer.py actually
  17. # runs instead of pytest-skipping with "index.html not present". Path matches
  18. # the production Dockerfile (static_dir.parent / "gcode_viewer" = /app/gcode_viewer/).
  19. COPY gcode_viewer/ ./gcode_viewer/
  20. # Create necessary directories
  21. RUN mkdir -p /app/data /app/logs /app/archive
  22. # Environment variables for testing
  23. ENV PYTHONUNBUFFERED=1
  24. ENV DATA_DIR=/app/data
  25. ENV TESTING=1
  26. # Default command runs pytest (excluding docker integration tests)
  27. CMD ["pytest", "backend/tests/", "-v", "--tb=short", "-p", "no:cacheprovider", "-n", "30"]
  28. # -------------------------------------------
  29. # Frontend test stage
  30. FROM node:22-bookworm-slim AS frontend-test
  31. WORKDIR /app/frontend
  32. # Copy package files and install
  33. COPY frontend/package*.json ./
  34. RUN npm ci
  35. # Copy frontend source
  36. COPY frontend/ ./
  37. # Default command runs tests
  38. CMD ["npm", "test", "--", "--run"]