version: '3.8' services: # Main API service opendistillery-api: build: context: . dockerfile: Dockerfile ports: - "8000:8000" environment: - ENVIRONMENT=production - API_WORKERS=4 - LOG_LEVEL=info - REDIS_URL=redis://redis:6379 - POSTGRES_URL=postgresql://user:password@postgres:5432/opendistillery - OPENAI_API_KEY=${OPENAI_API_KEY} - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} - GOOGLE_API_KEY=${GOOGLE_API_KEY} - COHERE_API_KEY=${COHERE_API_KEY} depends_on: - redis - postgres - prometheus volumes: - ./logs:/app/logs - ./models:/app/models restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/v2/system/health"] interval: 30s timeout: 10s retries: 3 # Background task processor celery-worker: build: context: . dockerfile: Dockerfile command: celery -A src.tasks.celery_app worker --loglevel=info --concurrency=4 environment: - REDIS_URL=redis://redis:6379 - POSTGRES_URL=postgresql://user:password@postgres:5432/opendistillery depends_on: - redis - postgres volumes: - ./logs:/app/logs restart: unless-stopped # Task scheduler celery-beat: build: context: . dockerfile: Dockerfile command: celery -A src.tasks.celery_app beat --loglevel=info environment: - REDIS_URL=redis://redis:6379 - POSTGRES_URL=postgresql://user:password@postgres:5432/opendistillery depends_on: - redis - postgres volumes: - ./logs:/app/logs restart: unless-stopped # Redis for caching and task queue redis: image: redis:7-alpine ports: - "6379:6379" volumes: - redis_data:/data restart: unless-stopped healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 30s timeout: 10s retries: 3 # PostgreSQL for persistent data postgres: image: postgres:15-alpine environment: - POSTGRES_DB=opendistillery - POSTGRES_USER=user - POSTGRES_PASSWORD=password ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data - ./init.sql:/docker-entrypoint-initdb.d/init.sql restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -U user -d opendistillery"] interval: 30s timeout: 10s retries: 3 # Prometheus for metrics prometheus: image: prom/prometheus:latest ports: - "9090:9090" volumes: - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml - prometheus_data:/prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--web.console.libraries=/etc/prometheus/console_libraries' - '--web.console.templates=/etc/prometheus/consoles' - '--web.enable-lifecycle' restart: unless-stopped # Grafana for dashboards grafana: image: grafana/grafana:latest ports: - "3000:3000" environment: - GF_SECURITY_ADMIN_PASSWORD=admin123 volumes: - grafana_data:/var/lib/grafana - ./monitoring/grafana/dashboards:/etc/grafana/provisioning/dashboards - ./monitoring/grafana/datasources:/etc/grafana/provisioning/datasources restart: unless-stopped # Nginx reverse proxy nginx: image: nginx:alpine ports: - "80:80" - "443:443" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./nginx/ssl:/etc/nginx/ssl - ./nginx/logs:/var/log/nginx depends_on: - opendistillery-api restart: unless-stopped # Model cache service model-cache: image: redis:7-alpine ports: - "6380:6379" volumes: - model_cache_data:/data command: redis-server --maxmemory 4gb --maxmemory-policy allkeys-lru restart: unless-stopped volumes: redis_data: postgres_data: prometheus_data: grafana_data: model_cache_data: networks: default: driver: bridge ipam: config: - subnet: 172.20.0.0/16