File size: 2,641 Bytes
69fec20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
80
81
82
83
84
85
86
version: '3.8'

services:
  gcli2api:
    image: ghcr.io/su-kaka/gcli2api:latest
    container_name: gcli2api
    restart: unless-stopped
    network_mode: host
    environment:
      # Password configuration (choose one)
      # Option 1: Use common password
      - PASSWORD=${PASSWORD:-pwd}
      # Option 2: Use separate passwords (uncomment if needed)
      # - API_PASSWORD=${API_PASSWORD:-your_api_password}
      # - PANEL_PASSWORD=${PANEL_PASSWORD:-your_panel_password}

      # Server configuration
      - PORT=${PORT:-7861}
      - HOST=${HOST:-0.0.0.0}

      # Optional: Google credentials from environment
      # - GOOGLE_CREDENTIALS=${GOOGLE_CREDENTIALS}

      # Optional: Logging configuration
      # - LOG_LEVEL=${LOG_LEVEL:-info}

      # Optional: Redis configuration (for distributed storage)
      # - REDIS_URI=${REDIS_URI}
      # - REDIS_DATABASE=${REDIS_DATABASE:-0}

      # Optional: MongoDB configuration (for distributed storage)
      # - MONGODB_URI=${MONGODB_URI}
      # - MONGODB_DATABASE=${MONGODB_DATABASE:-gcli2api}

      # Optional: PostgreSQL configuration (for distributed storage)
      # - POSTGRES_DSN=${POSTGRES_DSN}

      # Optional: Proxy configuration
      # - PROXY=${PROXY}
    volumes:
      - ./data/creds:/app/creds
    healthcheck:
      test: ["CMD-SHELL", "python -c \"import sys, urllib.request, os; port = os.environ.get('PORT', '7861'); req = urllib.request.Request(f'http://localhost:{port}/v1/models', headers={'Authorization': 'Bearer ' + os.environ.get('PASSWORD', 'pwd')}); sys.exit(0 if urllib.request.urlopen(req, timeout=5).getcode() == 200 else 1)\""]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

# Example with Redis for distributed storage
#  redis:
#    image: redis:7-alpine
#    container_name: gcli2api-redis
#    restart: unless-stopped
#    ports:
#      - "6379:6379"
#    volumes:
#      - redis_data:/data
#    command: redis-server --appendonly yes
#    healthcheck:
#      test: ["CMD", "redis-cli", "ping"]
#      interval: 10s
#      timeout: 3s
#      retries: 3

# Example with MongoDB for distributed storage
#  mongodb:
#    image: mongo:7
#    container_name: gcli2api-mongodb
#    restart: unless-stopped
#    environment:
#      MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER:-admin}
#      MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:-password}
#    ports:
#      - "27017:27017"
#    volumes:
#      - mongodb_data:/data/db
#    healthcheck:
#      test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
#      interval: 10s
#      timeout: 5s
#      retries: 3

#volumes:
#  redis_data:
#  mongodb_data: