File size: 2,066 Bytes
7f2e1a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
version: '3.8'

services:
  ocngx:
    build: .
    container_name: ocngx
    ports:
      - "7860:7860"
    environment:
      # 基本配置
      - GATEWAY_HOST=127.0.0.1
      - GATEWAY_PORT=3000
      - USERNAME=admin
      - PASSWORD=admin123
      
      # HuggingFace Spaces 自动检测的环境变量
      - SPACE_ID=${SPACE_ID:-}
      - OPENCODE_PUBLIC_URL=${OPENCODE_PUBLIC_URL:-http://localhost:7860}
      - PUBLIC_URL=${PUBLIC_URL:-http://localhost:7860}
      - BASE_URL=${BASE_URL:-http://localhost:7860}
      
      # 备份配置(可选)
      - BACKUP_S3_BUCKET=${BACKUP_S3_BUCKET:-}
      - BACKUP_DIR=${BACKUP_DIR:-/var/backups/ocngx}
      
      # 日志级别
      - LOG_LEVEL=${LOG_LEVEL:-info}
    
    volumes:
      # 持久化数据目录
      - opencode_data:/root/.opencode
      - backup_data:/var/backups/ocngx
      
      # 日志目录
      - ./logs:/var/log/nginx
      
      # 时区同步
      - /etc/localtime:/etc/localtime:ro
    
    restart: unless-stopped
    
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    
    networks:
      - ocngx_network

  # 可选:备份服务(用于自动备份到外部存储)
  backup-scheduler:
    image: alpine:latest
    container_name: ocngx-backup
    depends_on:
      - ocngx
    volumes:
      - backup_data:/backups:ro
      - ./backup-scripts:/scripts:ro
    environment:
      - BACKUP_S3_BUCKET=${BACKUP_S3_BUCKET:-}
      - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-}
      - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-}
      - AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-us-east-1}
    command: >
      sh -c "
        apk add --no-cache curl tar jq &&
        echo '0 2 * * * /scripts/backup.sh' > /etc/crontabs/root &&
        crond -f -l 2
      "
    restart: unless-stopped
    networks:
      - ocngx_network

volumes:
  opencode_data:
    driver: local
  backup_data:
    driver: local

networks:
  ocngx_network:
    driver: bridge