bambuddy/Dockerfile.test
2026-02-05 10:28:06 +01:00

46 lines
1.2 KiB
Text

# 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 ./
# 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)
# Use -n auto for parallel execution (auto-detects available CPUs)
CMD ["pytest", "backend/tests/", "-v", "--tb=short", "-p", "no:cacheprovider", "-n", "auto"]
# -------------------------------------------
# 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"]