Files
AIRouter/docker-compose.yml

57 lines
1.3 KiB
YAML

services:
# 后端服务
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: ai-router-backend
restart: unless-stopped
ports:
- "8080:8080"
environment:
# 数据库文件路径(映射到数据卷)
- DB_PATH=/app/data/gateway.db
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
# 前端服务
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: ai-router-frontend
restart: unless-stopped
ports:
- "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
# 数据卷定义
volumes:
backend-data:
driver: local
name: ai-router-backend-data
# 网络定义
networks:
ai-router-network:
driver: bridge
name: ai-router-network