| version: '3.8' | |
| ################################################################################ | |
| # CodePilot Production Docker Compose Configuration | |
| # Deploys Chainlit UI with Gemini integration on GCP VM | |
| ################################################################################ | |
| services: | |
| codepilot: | |
| build: | |
| context: . | |
| dockerfile: Dockerfile | |
| container_name: codepilot | |
| # Restart policy - always restart unless explicitly stopped | |
| restart: unless-stopped | |
| # Port mapping: Host:Container | |
| # Chainlit runs on 7860 internally, exposed as 8000 externally | |
| ports: | |
| - "8000:7860" | |
| # Load environment variables from .env file | |
| env_file: | |
| - .env | |
| # Override specific environment variables | |
| environment: | |
| - PORT=7860 | |
| - HOST=0.0.0.0 | |
| - PYTHONUNBUFFERED=1 # Ensure logs appear in docker logs | |
| # Volume mounts for persistence | |
| volumes: | |
| # Persist cloned GitHub repositories | |
| - codepilot_data:/home/user/app/data | |
| # Optional: Mount logs directory | |
| - codepilot_logs:/home/user/app/logs | |
| # Resource limits to prevent OOM and CPU throttling | |
| deploy: | |
| resources: | |
| limits: | |
| memory: 4G # Maximum memory | |
| cpus: '2.0' # Maximum CPU cores | |
| reservations: | |
| memory: 2G # Guaranteed memory | |
| cpus: '1.0' # Guaranteed CPU cores | |
| # Health check to monitor service status | |
| healthcheck: | |
| test: ["CMD", "curl", "-f", "http://localhost:7860"] | |
| interval: 30s # Check every 30 seconds | |
| timeout: 10s # Wait 10s for response | |
| retries: 3 # Restart after 3 failed checks | |
| start_period: 40s # Give 40s for initial startup | |
| # Logging configuration | |
| logging: | |
| driver: "json-file" | |
| options: | |
| max-size: "10m" # Max 10MB per log file | |
| max-file: "3" # Keep 3 rotated log files | |
| # Named volumes for data persistence (Docker-managed) | |
| volumes: | |
| codepilot_data: | |
| codepilot_logs: | |
| ################################################################################ | |
| # Usage: | |
| # docker compose up -d # Start in background | |
| # docker compose logs -f # View logs | |
| # docker compose ps # Check status | |
| # docker compose down # Stop and remove | |
| # docker compose restart # Restart service | |
| ################################################################################ | |