kankwa/docker-compose.e2e.yml

82 lines
2.4 KiB
YAML

name: kankwa-e2e-real
x-api-environment: &api-environment
DATABASE_URL: postgresql+asyncpg://kankwa_e2e:kankwa_e2e_password@db:5432/kankwa_e2e
SECRET_KEY: e2e-only-secret-key-not-for-production
ENVIRONMENT: test
FRONTEND_URL: http://frontend:4173
FRONTEND_URL_EN: http://frontend:4173
PYTHONDONTWRITEBYTECODE: "1"
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: kankwa_e2e
POSTGRES_PASSWORD: kankwa_e2e_password
POSTGRES_DB: kankwa_e2e
healthcheck:
test: ["CMD-SHELL", "pg_isready -U kankwa_e2e -d kankwa_e2e"]
interval: 2s
timeout: 3s
retries: 20
tmpfs:
- /var/lib/postgresql/data
migrate:
build: .
environment: *api-environment
command: ["python", "-m", "alembic", "upgrade", "head"]
depends_on:
db:
condition: service_healthy
api:
build: .
environment: *api-environment
command: ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
depends_on:
migrate:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "python", "-c", "from urllib.request import urlopen; urlopen('http://127.0.0.1:8000/ready', timeout=3)"]
interval: 2s
timeout: 3s
retries: 20
frontend:
image: node:20-alpine
working_dir: /workspace
volumes:
- ./frontend:/workspace
- frontend_node_modules:/workspace/node_modules
environment:
VITE_API_PROXY_TARGET: http://api:8000
command: sh -c "npm ci && npm run dev -- --host 0.0.0.0 --port 4173"
depends_on:
api:
condition: service_healthy
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:4173/').then(r => { if (!r.ok) process.exit(1) }).catch(() => process.exit(1))"]
interval: 2s
timeout: 3s
retries: 30
playwright:
image: mcr.microsoft.com/playwright:v1.62.1-noble
working_dir: /workspace
volumes:
- ./frontend:/workspace
- playwright_node_modules:/workspace/node_modules
environment:
CI: "1"
E2E_BASE_URL: http://frontend:4173
E2E_DATABASE_URL: postgresql://kankwa_e2e:kankwa_e2e_password@db:5432/kankwa_e2e
command: sh -c "npm ci && npx playwright test --config=playwright.real.config.ts"
depends_on:
frontend:
condition: service_healthy
volumes:
frontend_node_modules:
playwright_node_modules: