Files
docker-swarm-termina/backend/Dockerfile
Claude cd16fbc6bb Add tests with coverage and e2e to Docker build process
- Update backend Dockerfile with multi-stage build that runs pytest
  with coverage (70% threshold) before production build
- Update frontend Dockerfile with multi-stage build including:
  - Unit test stage with Jest coverage
  - E2E test stage with Playwright
  - Production stage depends on test stages via markers
- Add Playwright e2e tests for login, dashboard, and terminal flows
- Configure Playwright with chromium browser
- Update jest.config.js to exclude e2e directory
- Update docker-compose.yml to target production stage

https://claude.ai/code/session_01XSQJybTpvKyN7td4Y8n5Rm
2026-02-01 17:10:32 +00:00

41 lines
1.0 KiB
Docker

# Build and test stage
FROM python:3.11-slim AS test
WORKDIR /app
# Install dependencies (both production and dev)
COPY requirements.txt requirements-dev.txt ./
RUN pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
# Copy application
COPY . .
# Run tests with coverage and generate test-passed marker
RUN pytest --cov=. --cov-report=term-missing --cov-report=xml --cov-branch --cov-fail-under=70 -v \
&& touch /app/.tests-passed
# Production stage
FROM python:3.11-slim AS production
WORKDIR /app
# Copy test verification marker from test stage (ensures tests passed)
COPY --from=test /app/.tests-passed /tmp/.tests-passed
# Install production dependencies only
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application
COPY . .
# Expose port
EXPOSE 5000
# Run as root to access Docker socket (required for Docker API access)
# In production, you may want to use a specific user with docker group permissions
USER root
# Run the application
CMD ["python", "app.py"]