Add analytics service for platform-wide metrics and tracking. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
137 lines
4.3 KiB
YAML
137 lines
4.3 KiB
YAML
version: '3.8'
|
|
|
|
# Analytics Service Docker Compose
|
|
# Run standalone or include in main platform compose
|
|
|
|
services:
|
|
# =============================================================================
|
|
# ANALYTICS SERVICE: Event tracking, dashboards, and reporting
|
|
# =============================================================================
|
|
analytics:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
container_name: lilith-analytics-service
|
|
restart: unless-stopped
|
|
ports:
|
|
- '31800:3000'
|
|
environment:
|
|
NODE_ENV: ${NODE_ENV:-development}
|
|
PORT: 3000
|
|
|
|
# Database - PostgreSQL for analytics data
|
|
DATABASE_HOST: ${DATABASE_HOST:-postgres}
|
|
DATABASE_PORT: ${DATABASE_PORT:-5432}
|
|
DATABASE_NAME: ${DATABASE_NAME:-lilith_analytics}
|
|
DATABASE_USER: ${DATABASE_USER:-lilith}
|
|
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-dev-password}
|
|
DATABASE_SSL: ${DATABASE_SSL:-false}
|
|
|
|
# Redis - For BullMQ job processing and caching
|
|
REDIS_HOST: ${REDIS_HOST:-redis}
|
|
REDIS_PORT: ${REDIS_PORT:-6379}
|
|
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
|
REDIS_DB: ${REDIS_DB:-1}
|
|
|
|
# Service Registry - Auto-discovery
|
|
SERVICE_REGISTRY_URL: ${SERVICE_REGISTRY_URL:-http://service-registry:31700}
|
|
SERVICE_REGISTRY_API_KEY: ${SERVICE_REGISTRY_API_KEY:-dev-api-key}
|
|
|
|
# Security - Authentication
|
|
JWT_SECRET: ${JWT_SECRET:-dev-jwt-secret-change-in-production}
|
|
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-24h}
|
|
|
|
# CORS - Comma-separated origins
|
|
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-http://localhost:3000,http://localhost:5173}
|
|
|
|
# Analytics Configuration
|
|
ANALYTICS_BATCH_SIZE: ${ANALYTICS_BATCH_SIZE:-100}
|
|
ANALYTICS_BATCH_INTERVAL_MS: ${ANALYTICS_BATCH_INTERVAL_MS:-5000}
|
|
ANALYTICS_RETENTION_DAYS: ${ANALYTICS_RETENTION_DAYS:-365}
|
|
|
|
# Background Jobs
|
|
QUEUE_CONCURRENCY: ${QUEUE_CONCURRENCY:-5}
|
|
QUEUE_MAX_ATTEMPTS: ${QUEUE_MAX_ATTEMPTS:-3}
|
|
|
|
labels:
|
|
# Service Registry Integration
|
|
com.lilith.service.name: "analytics"
|
|
com.lilith.service.type: "api"
|
|
com.lilith.service.health: "/health"
|
|
com.lilith.service.dependencies: "postgres,redis"
|
|
com.lilith.service.version: "1.0.0"
|
|
com.lilith.service.description: "Analytics service - event tracking and reporting"
|
|
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
|
|
healthcheck:
|
|
test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:3000/health']
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 10s
|
|
|
|
networks:
|
|
- lilith-network
|
|
|
|
volumes:
|
|
- analytics-uploads:/data/uploads
|
|
- analytics-cache:/data/cache
|
|
|
|
# =============================================================================
|
|
# POSTGRES: Analytics database
|
|
# =============================================================================
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
container_name: lilith-analytics-postgres
|
|
restart: unless-stopped
|
|
ports:
|
|
- '5433:5432' # Different port to avoid conflicts
|
|
environment:
|
|
POSTGRES_DB: ${DATABASE_NAME:-lilith_analytics}
|
|
POSTGRES_USER: ${DATABASE_USER:-lilith}
|
|
POSTGRES_PASSWORD: ${DATABASE_PASSWORD:-dev-password}
|
|
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C"
|
|
volumes:
|
|
- analytics-postgres-data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ['CMD-SHELL', 'pg_isready -U ${DATABASE_USER:-lilith}']
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- lilith-network
|
|
|
|
# =============================================================================
|
|
# REDIS: Job queue and caching
|
|
# =============================================================================
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: lilith-analytics-redis
|
|
restart: unless-stopped
|
|
ports:
|
|
- '6381:6379' # Different port to avoid conflicts
|
|
volumes:
|
|
- analytics-redis-data:/data
|
|
command: redis-server --appendonly yes
|
|
healthcheck:
|
|
test: ['CMD', 'redis-cli', 'ping']
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
networks:
|
|
- lilith-network
|
|
|
|
volumes:
|
|
analytics-postgres-data:
|
|
analytics-redis-data:
|
|
analytics-uploads:
|
|
analytics-cache:
|
|
|
|
networks:
|
|
lilith-network:
|
|
driver: bridge
|