version: '3.8' services: # PostgreSQL测试数据库服务 postgres-test: image: postgres:15-alpine container_name: novalon-postgres-test environment: POSTGRES_DB: manage_system_test POSTGRES_USER: novalon_test POSTGRES_PASSWORD: novalon_test123 ports: - "55433:5432" volumes: - postgres_test_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U novalon_test -d manage_system_test"] interval: 10s timeout: 5s retries: 5 networks: - novalon-test-network # 后端API测试服务 backend-test: build: context: ./novalon-manage-api dockerfile: Dockerfile container_name: novalon-backend-test environment: SPRING_PROFILES_ACTIVE: test SPRING_R2DBC_URL: r2dbc:postgresql://postgres-test:5432/manage_system_test SPRING_R2DBC_USERNAME: novalon_test SPRING_R2DBC_PASSWORD: novalon_test123 SPRING_JPA_HIBERNATE_DDL_AUTO: update ports: - "8085:8084" depends_on: postgres-test: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8084/actuator/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - novalon-test-network volumes: - ./test-results:/app/test-results # 前端Web测试服务 frontend-test: build: context: ./novalon-manage-web dockerfile: Dockerfile container_name: novalon-frontend-test ports: - "3002:80" depends_on: backend-test: condition: service_healthy environment: - VITE_API_BASE_URL=http://backend-test:8084 - NODE_ENV=test healthcheck: test: ["CMD", "curl", "-f", "http://localhost:80"] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - novalon-test-network volumes: - ./test-results:/app/test-results # Playwright测试服务 playwright-test: build: context: ./novalon-manage-web dockerfile: Dockerfile.playwright container_name: novalon-playwright-test depends_on: frontend-test: condition: service_healthy environment: - BASE_URL=http://frontend-test:80 - CI=true networks: - novalon-test-network volumes: - ./test-results:/app/test-results - ./playwright-report:/app/playwright-report command: > sh -c " echo 'Waiting for frontend to be ready...' && sleep 10 && echo 'Starting Playwright tests...' && npx playwright test --reporter=json --reporter=html --reporter=junit " volumes: postgres_test_data: driver: local networks: novalon-test-network: driver: bridge