60 lines
1.4 KiB
YAML
60 lines
1.4 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# 后端API服务 - 使用外部Redis
|
|
backend:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile.backend
|
|
container_name: stockagent-backend
|
|
restart: unless-stopped
|
|
ports:
|
|
- "8050:8050"
|
|
environment:
|
|
- TUSHARE_TOKEN=${TUSHARE_TOKEN}
|
|
- REDIS_HOST=host.docker.internal # 连接到宿主机的Redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_DB=0 # 可以使用不同的数据库编号避免冲突
|
|
- API_HOST=0.0.0.0
|
|
- API_PORT=8050
|
|
volumes:
|
|
- ./logs:/app/logs
|
|
- ./config:/app/config
|
|
networks:
|
|
- stockagent-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8050/"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
extra_hosts:
|
|
- "host.docker.internal:host-gateway"
|
|
|
|
# 前端Web服务
|
|
frontend:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile.frontend
|
|
container_name: stockagent-frontend
|
|
restart: unless-stopped
|
|
ports:
|
|
- "5001:5001"
|
|
environment:
|
|
- API_BASE_URL=http://backend:8050/api
|
|
depends_on:
|
|
- backend
|
|
networks:
|
|
- stockagent-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:5001/"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 20s
|
|
|
|
# 网络配置
|
|
networks:
|
|
stockagent-network:
|
|
driver: bridge
|
|
name: stockagent-network |