316 lines
11 KiB
YAML
Executable file
316 lines
11 KiB
YAML
Executable file
# =============================================================================
|
|
# Platform Admin E2E Docker Environment
|
|
# =============================================================================
|
|
# Self-contained test environment for full platform-admin E2E testing.
|
|
# Sets up PostgreSQL, seeds data, runs all backend services, and frontend.
|
|
#
|
|
# Usage:
|
|
# docker compose -f e2e/docker-compose.e2e.yml up --build --abort-on-container-exit
|
|
# docker compose -f e2e/docker-compose.e2e.yml down -v
|
|
#
|
|
# Services:
|
|
# - postgres: Analytics database with seeded data for all routes
|
|
# - redis: Cache for backend services
|
|
# - analytics-api: Analytics backend API
|
|
# - platform-admin-api: Admin BFF (Backend For Frontend)
|
|
# - conversation-assistant-api: Conversation AI backend (scammers, training)
|
|
# - platform-admin: Frontend under test
|
|
# - e2e-runner: Playwright test runner
|
|
#
|
|
# NOTE: email-api is disabled due to NestJS dependency issue
|
|
# (EmailTemplateEntityRepository not available in AdminModule)
|
|
# =============================================================================
|
|
|
|
services:
|
|
# TimescaleDB database for analytics (required for create_hypertable)
|
|
postgres:
|
|
image: timescale/timescaledb:latest-pg16
|
|
environment:
|
|
POSTGRES_USER: analytics
|
|
POSTGRES_PASSWORD: analytics_e2e_test
|
|
POSTGRES_DB: analytics_e2e
|
|
volumes:
|
|
# Schema and seed data (files run in alphabetical order)
|
|
- ./fixtures/00-e2e-schema.sql:/docker-entrypoint-initdb.d/00-e2e-schema.sql:ro
|
|
- ../../../analytics/database/schema.sql:/docker-entrypoint-initdb.d/01-analytics-schema.sql:ro
|
|
- ./fixtures/seed-conversion-events.sql:/docker-entrypoint-initdb.d/02-seed-conversion.sql:ro
|
|
- ./fixtures/seed-analytics.sql:/docker-entrypoint-initdb.d/03-seed-analytics.sql:ro
|
|
- ./fixtures/04-platform-admin-schema.sql:/docker-entrypoint-initdb.d/04-platform-admin-schema.sql:ro
|
|
- ./fixtures/06-marketplace-schema.sql:/docker-entrypoint-initdb.d/06-marketplace-schema.sql:ro
|
|
- ./fixtures/07-seed-platform-admin.sql:/docker-entrypoint-initdb.d/07-seed-platform-admin.sql:ro
|
|
- ./fixtures/09-seed-marketplace.sql:/docker-entrypoint-initdb.d/09-seed-marketplace.sql:ro
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U analytics -d analytics_e2e"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 10s
|
|
networks:
|
|
- e2e-network
|
|
|
|
# Redis for analytics caching
|
|
redis:
|
|
image: redis:7-alpine
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
networks:
|
|
- e2e-network
|
|
|
|
# Analytics Backend API
|
|
analytics-api:
|
|
build:
|
|
context: ../../../..
|
|
dockerfile: features/analytics/backend-api/Dockerfile.e2e
|
|
args:
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.black.local/}
|
|
# VPN host entry for Forgejo registry - required during build for pnpm install
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
# Runtime extra_hosts (for container networking)
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
environment:
|
|
# Use production mode to disable TypeORM synchronize (sync conflicts with TimescaleDB hypertables)
|
|
NODE_ENV: production
|
|
PORT: 3012
|
|
# Database connection
|
|
DATABASE_HOST: postgres
|
|
DATABASE_PORT: 5432
|
|
DATABASE_USER: analytics
|
|
DATABASE_PASSWORD: analytics_e2e_test
|
|
DATABASE_NAME: analytics_e2e
|
|
# Redis connection
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: 6379
|
|
# Disable auth for E2E tests
|
|
DISABLE_AUTH: "true"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3012/api/health"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 30s
|
|
networks:
|
|
- e2e-network
|
|
|
|
# Platform Admin Backend API (BFF for shop, merch, queues, devices, scammers)
|
|
platform-admin-api:
|
|
build:
|
|
context: ../../../..
|
|
dockerfile: features/platform-admin/backend-api/Dockerfile.e2e
|
|
args:
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.black.local/}
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
environment:
|
|
NODE_ENV: production
|
|
PORT: 3011
|
|
# Database - uses DB_* prefix (not DATABASE_*)
|
|
DB_HOST: postgres
|
|
DB_PORT: 5432
|
|
DB_USERNAME: analytics
|
|
DB_PASSWORD: analytics_e2e_test
|
|
DB_DATABASE: analytics_e2e
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: 6379
|
|
DISABLE_AUTH: "true"
|
|
# Service URLs for proxying
|
|
ANALYTICS_API_URL: http://analytics-api:3012
|
|
EMAIL_API_URL: http://email-api:3013
|
|
ATTRIBUTES_API_URL: http://attributes-api:3015
|
|
CONVERSATION_ASSISTANT_API_URL: http://conversation-assistant-api:3100
|
|
MARKETPLACE_API_URL: http://marketplace-api:3001
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
# platform-admin-api has no /health endpoint - use /docs (Swagger)
|
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3011/docs"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 30s
|
|
networks:
|
|
- e2e-network
|
|
|
|
# Conversation Assistant Backend API (scammers, training, ML models)
|
|
conversation-assistant-api:
|
|
build:
|
|
context: ../../../..
|
|
dockerfile: features/conversation-assistant/backend-api/Dockerfile.e2e
|
|
args:
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.black.local/}
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
environment:
|
|
NODE_ENV: production
|
|
PORT: 3100
|
|
DB_HOST: postgres
|
|
DB_PORT: 5432
|
|
DB_USER: analytics
|
|
DB_PASSWORD: analytics_e2e_test
|
|
DB_NAME: analytics_e2e
|
|
DISABLE_AUTH: "true"
|
|
# Disable TypeORM migrations - we use SQL schema files in E2E
|
|
MIGRATIONS_RUN: "false"
|
|
# ML service URL (not running in E2E, but needed for config)
|
|
ML_SERVICE_URL: http://localhost:8100
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3100/api/health"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 30s
|
|
networks:
|
|
- e2e-network
|
|
|
|
# Marketplace API (subscription tiers, experiments, billing)
|
|
marketplace-api:
|
|
build:
|
|
context: ../../../..
|
|
dockerfile: features/marketplace/backend-api/Dockerfile.e2e
|
|
args:
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.black.local/}
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
environment:
|
|
NODE_ENV: production
|
|
PORT: 3001
|
|
# Database - uses DB_* prefix
|
|
DB_HOST: postgres
|
|
DB_PORT: 5432
|
|
DB_USERNAME: analytics
|
|
DB_PASSWORD: analytics_e2e_test
|
|
DB_NAME: analytics_e2e
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: 6379
|
|
DISABLE_AUTH: "true"
|
|
# Disable BullMQ queues to avoid @nestjs/bullmq module initialization issues
|
|
# Analytics event tracking not needed in E2E tests
|
|
DISABLE_QUEUES: "true"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3001/health"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 30s
|
|
networks:
|
|
- e2e-network
|
|
|
|
# NOTE: email-api disabled - NestJS dependency bug (EmailTemplateEntityRepository)
|
|
# Re-enable when features/email/backend-api AdminModule is fixed
|
|
|
|
# NOTE: attributes-api disabled - needs schema migration (attribute_definitions table)
|
|
# Re-enable when e2e/fixtures/ includes attributes schema SQL
|
|
|
|
# Platform Admin Frontend
|
|
platform-admin:
|
|
build:
|
|
context: ../../../..
|
|
dockerfile: features/platform-admin/frontend-admin/Dockerfile.e2e
|
|
args:
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.black.local/}
|
|
# VPN host entry for Forgejo registry - required during build for pnpm install
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
# Runtime extra_hosts (for container networking)
|
|
extra_hosts:
|
|
- "npm.black.local:10.0.0.11"
|
|
- "forge.black.local:10.0.0.11"
|
|
environment:
|
|
# Backend service URLs for Vite proxy
|
|
VITE_API_URL: http://platform-admin-api:3011
|
|
VITE_ANALYTICS_URL: http://analytics-api:3012
|
|
VITE_CONVERSATION_ASSISTANT_URL: http://conversation-assistant-api:3100
|
|
VITE_MARKETPLACE_URL: http://marketplace-api:3001
|
|
# Disabled services:
|
|
# VITE_EMAIL_URL: disabled - email-api has NestJS bug
|
|
# VITE_ATTRIBUTES_URL: disabled - needs schema migration
|
|
ports:
|
|
- "3210:5173"
|
|
depends_on:
|
|
analytics-api:
|
|
condition: service_healthy
|
|
platform-admin-api:
|
|
condition: service_healthy
|
|
conversation-assistant-api:
|
|
condition: service_healthy
|
|
marketplace-api:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
# Use 127.0.0.1 instead of localhost - wget prefers IPv6 (::1) but Node binds to IPv4
|
|
test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:5173"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 30s
|
|
networks:
|
|
- e2e-network
|
|
|
|
# Playwright E2E Test Runner
|
|
# Uses dedicated e2e/package.json with only Playwright dependencies
|
|
e2e-runner:
|
|
image: mcr.microsoft.com/playwright:v1.49.0-jammy
|
|
working_dir: /tests
|
|
environment:
|
|
CI: "true"
|
|
BASE_URL: http://platform-admin:5173
|
|
API_URL: http://analytics-api:3012
|
|
ADMIN_API_URL: http://platform-admin-api:3011
|
|
CONVERSATION_ASSISTANT_API_URL: http://conversation-assistant-api:3100
|
|
MARKETPLACE_API_URL: http://marketplace-api:3001
|
|
# Disabled:
|
|
# EMAIL_API_URL: email-api has NestJS bug
|
|
# ATTRIBUTES_API_URL: needs schema migration
|
|
volumes:
|
|
# Mount just the e2e directory with its own package.json
|
|
- .:/tests
|
|
- ./test-results:/tests/test-results
|
|
depends_on:
|
|
platform-admin:
|
|
condition: service_healthy
|
|
command: >
|
|
sh -c "
|
|
npm install &&
|
|
npx playwright install chromium &&
|
|
npx playwright test *.docker.e2e.ts --config=playwright.docker.config.ts
|
|
"
|
|
networks:
|
|
- e2e-network
|
|
|
|
networks:
|
|
e2e-network:
|
|
driver: bridge
|