60 lines
1.9 KiB
YAML
60 lines
1.9 KiB
YAML
services:
|
||
droid2api:
|
||
build: .
|
||
container_name: droid2api
|
||
ports:
|
||
- "3001:3000"
|
||
environment:
|
||
# 认证配置(按优先级选择其一):
|
||
# 最高优先级:固定API密钥(推荐用于生产环境)
|
||
- FACTORY_API_KEY=${FACTORY_API_KEY}
|
||
# 次优先级:refresh token自动刷新机制
|
||
- DROID_REFRESH_KEY=${DROID_REFRESH_KEY}
|
||
# 可选:如果需要修改端口,在config.json中配置
|
||
# 阿里云日志服务配置
|
||
- ALIYUN_ACCESS_KEY_ID=${ALIYUN_ACCESS_KEY_ID}
|
||
- ALIYUN_ACCESS_KEY_SECRET=${ALIYUN_ACCESS_KEY_SECRET}
|
||
- ALIYUN_SLS_ENDPOINT=${ALIYUN_SLS_ENDPOINT}
|
||
- ALIYUN_SLS_PROJECT=${ALIYUN_SLS_PROJECT}
|
||
- ALIYUN_SLS_LOGSTORE=${ALIYUN_SLS_LOGSTORE}
|
||
# API 认证中间件
|
||
- AUTH_ENABLED=${AUTH_ENABLED:-false}
|
||
- API_KEYS=${API_KEYS}
|
||
volumes:
|
||
# 可选:持久化auth.json以保存刷新的tokens
|
||
- ./data:/app/data
|
||
# 多账号配置文件(由 sync-accounts.sh 同步)
|
||
- ./accounts.json:/app/accounts.json:ro
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/"]
|
||
interval: 30s
|
||
timeout: 10s
|
||
retries: 3
|
||
start_period: 40s
|
||
networks:
|
||
- api-network
|
||
|
||
# Cloudflare Tunnel (可选)
|
||
# 启用方式: docker compose --profile tunnel up -d
|
||
# 需要在 .env 中设置 TUNNEL_TOKEN
|
||
tunnel:
|
||
image: cloudflare/cloudflared:latest
|
||
container_name: droid2api_tunnel
|
||
restart: unless-stopped
|
||
command: tunnel run
|
||
environment:
|
||
- TUNNEL_TOKEN=${TUNNEL_TOKEN}
|
||
depends_on:
|
||
- droid2api
|
||
profiles:
|
||
- tunnel
|
||
networks:
|
||
- api-network
|
||
|
||
# 共享网络配置 - 支持与 new-api 等其他服务独立部署但可互通
|
||
# 首次使用需先创建网络: docker network create api-network
|
||
networks:
|
||
api-network:
|
||
external: true
|