File size: 2,476 Bytes
b29a1f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
################################################################################