services: db: image: pgvector/pgvector:pg17 volumes: - postgres_data:/var/lib/postgresql/data/ # Note: Port not exposed in production for security # Access via internal network only environment: - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_DB=${POSTGRES_DB} healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"] interval: 5s timeout: 5s retries: 5 networks: - app-network restart: unless-stopped redis: image: redis:7-alpine volumes: - redis_data:/data command: redis-server --appendonly yes healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 5s retries: 5 networks: - app-network restart: unless-stopped backend: build: context: ./backend dockerfile: Dockerfile target: production ports: - "8000:8000" env_file: - .env environment: - DATABASE_URL=${DATABASE_URL} - SECRET_KEY=${SECRET_KEY} - ENVIRONMENT=production - DEBUG=false - BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS} - REDIS_URL=redis://redis:6379/0 depends_on: db: condition: service_healthy redis: condition: service_healthy networks: - app-network restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s # Celery workers for background task processing (per ADR-003) celery-agent: build: context: ./backend dockerfile: Dockerfile target: production env_file: - .env environment: - DATABASE_URL=${DATABASE_URL} - REDIS_URL=redis://redis:6379/0 - CELERY_QUEUE=agent depends_on: db: condition: service_healthy redis: condition: service_healthy networks: - app-network restart: unless-stopped command: ["celery", "-A", "app.celery_app", "worker", "-Q", "agent", "-l", "info", "-c", "4"] deploy: resources: limits: cpus: '2.0' memory: 4G reservations: cpus: '0.5' memory: 512M celery-git: build: context: ./backend dockerfile: Dockerfile target: production env_file: - .env environment: - DATABASE_URL=${DATABASE_URL} - REDIS_URL=redis://redis:6379/0 - CELERY_QUEUE=git depends_on: db: condition: service_healthy redis: condition: service_healthy networks: - app-network restart: unless-stopped command: ["celery", "-A", "app.celery_app", "worker", "-Q", "git", "-l", "info", "-c", "2"] deploy: resources: limits: cpus: '1.0' memory: 2G reservations: cpus: '0.25' memory: 256M celery-sync: build: context: ./backend dockerfile: Dockerfile target: production env_file: - .env environment: - DATABASE_URL=${DATABASE_URL} - REDIS_URL=redis://redis:6379/0 - CELERY_QUEUE=sync depends_on: db: condition: service_healthy redis: condition: service_healthy networks: - app-network restart: unless-stopped command: ["celery", "-A", "app.celery_app", "worker", "-Q", "sync", "-l", "info", "-c", "2"] deploy: resources: limits: cpus: '1.0' memory: 2G reservations: cpus: '0.25' memory: 256M celery-beat: build: context: ./backend dockerfile: Dockerfile target: production env_file: - .env environment: - DATABASE_URL=${DATABASE_URL} - REDIS_URL=redis://redis:6379/0 depends_on: db: condition: service_healthy redis: condition: service_healthy networks: - app-network restart: unless-stopped command: ["celery", "-A", "app.celery_app", "beat", "-l", "info"] deploy: resources: limits: cpus: '0.5' memory: 512M reservations: cpus: '0.1' memory: 128M frontend: build: context: ./frontend dockerfile: Dockerfile target: runner args: - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} ports: - "3000:3000" environment: - NODE_ENV=production - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} depends_on: backend: condition: service_healthy networks: - app-network restart: unless-stopped volumes: postgres_data: redis_data: networks: app-network: driver: bridge