platform-codebase/features/seo/docker-compose.e2e.yml

123 lines
3.2 KiB
YAML
Executable file

# SEO E2E Test Environment
#
# Self-contained Docker environment for Playwright E2E tests.
# Includes PostgreSQL, Redis, API, and both frontend apps.
#
# Usage:
# docker compose -f docker-compose.e2e.yml up --build --abort-on-container-exit
# docker compose -f docker-compose.e2e.yml down -v
services:
# PostgreSQL database
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: e2e_user
POSTGRES_PASSWORD: e2e_password
POSTGRES_DB: seo_e2e
healthcheck:
test: ["CMD-SHELL", "pg_isready -U e2e_user -d seo_e2e"]
interval: 5s
timeout: 3s
retries: 10
volumes:
- ./e2e/seed.sql:/docker-entrypoint-initdb.d/01-seed.sql:ro
networks:
- e2e-network
# Redis for BullMQ queues and caching
redis:
image: redis:7-alpine
command: redis-server --appendonly yes
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
networks:
- e2e-network
# Backend API (NestJS with PostgreSQL + Redis)
api:
build:
context: .
dockerfile: e2e/Dockerfile.api
args:
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.nasty.sh/}
environment:
NODE_ENV: test
PORT: 3014
# Database connection
DATABASE_HOST: postgres
DATABASE_PORT: 5432
DATABASE_USER: e2e_user
DATABASE_PASSWORD: e2e_password
DATABASE_NAME: seo_e2e
DATABASE_SYNCHRONIZE: "true"
# Redis connection
REDIS_HOST: redis
REDIS_PORT: 6379
# Disable auto-start of dependencies in Docker
LILITH_DEPENDENCY_STARTUP_DISABLED: "true"
# CORS origins
ALLOWED_ORIGINS: "http://localhost:4003,http://frontend:4003"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3014/api/seo/health"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
networks:
- e2e-network
# Frontend Public (Vite preview server)
frontend:
build:
context: .
dockerfile: e2e/Dockerfile.frontend
args:
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.nasty.sh/}
environment:
NODE_ENV: test
VITE_API_URL: http://api:3014
depends_on:
api:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:4003"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
networks:
- e2e-network
# Playwright E2E test runner
e2e-tests:
build:
context: .
dockerfile: e2e/Dockerfile.e2e
args:
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.nasty.sh/}
environment:
CI: "true"
BASE_URL: http://frontend:4003
API_URL: http://api:3014
depends_on:
frontend:
condition: service_healthy
volumes:
- ./frontend-public/test-results:/app/test-results
- ./frontend-public/playwright-report:/app/playwright-report
command: ["pnpm", "exec", "playwright", "test", "--config=playwright.docker.config.ts"]
networks:
- e2e-network
networks:
e2e-network:
driver: bridge