# Docker Compose 配置文件(国内网络优化版) # 使用国内镜像源优化的 Dockerfile # 适用于网络访问 Docker Hub 受限的环境 services: # 后端服务 (Go API) backend: build: context: ./backend dockerfile: Dockerfile.cn # 使用国内优化版 Dockerfile container_name: ai-router-backend restart: unless-stopped ports: - "${BACKEND_PORT:-8080}:8080" environment: - DB_PATH=${DB_PATH:-/app/data/gateway.db} - TZ=Asia/Shanghai volumes: # 持久化数据库文件 - backend-data:/app/data networks: - ai-router-network healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "-O", "/dev/null", "http://backend:8080/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s # 前端服务 (React + Nginx) frontend: build: context: ./frontend dockerfile: Dockerfile.cn # 使用国内优化版 Dockerfile container_name: ai-router-frontend restart: unless-stopped ports: - "${FRONTEND_PORT:-3000}:80" depends_on: backend: condition: service_healthy networks: - ai-router-network healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://frontend:80/health"] interval: 30s timeout: 10s retries: 3 start_period: 20s # 网络配置 networks: ai-router-network: driver: bridge name: ai-router-network # 数据卷配置 volumes: backend-data: driver: local name: ai-router-backend-data