version: '3.8' # QuantScope v1.0.0-preview Docker Compose配置 # 支持前后端分离部署 services: # FastAPI 后端服务 backend: build: context: . # dockerfile: Dockerfile.backend-dev dockerfile: Dockerfile.backend image: quantscope-backend:v1.0.1 container_name: quantscope-backend ports: - "8000:8000" volumes: # 本地代码热更新(覆盖镜像内代码) - ./app:/app/app - ./tradingagents:/app/tradingagents - ./mcp_servers:/app/mcp_servers # 日志目录映射 - ./logs:/app/logs # 配置目录映射 - ./config:/app/config # 数据目录映射 - ./data:/app/data command: ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] env_file: - .env dns: - 223.5.5.5 - 119.29.29.29 - 8.8.8.8 environment: PYTHONPATH: "/app/tradingagents:/app" PYTHONUNBUFFERED: 1 PYTHONDONTWRITEBYTECODE: 1 TZ: "Asia/Shanghai" # 日志配置 TRADINGAGENTS_LOG_LEVEL: "INFO" TRADINGAGENTS_LOG_DIR: "/app/logs" TRADINGAGENTS_LOG_FILE: "/app/logs/tradingagents.log" # Docker专用数据库配置 TRADINGAGENTS_MONGODB_URL: mongodb://admin:tradingagents123@mongodb:27017/tradingagents?authSource=admin TRADINGAGENTS_REDIS_URL: redis://:tradingagents123@redis:6379 TRADINGAGENTS_CACHE_TYPE: redis # Docker环境标识 DOCKER_CONTAINER: "true" # API配置 API_HOST: "0.0.0.0" API_PORT: "8000" # Redis配置(供 QuantScope 后端使用) REDIS_HOST: "redis" REDIS_PORT: "6379" REDIS_PASSWORD: "tradingagents123" # CORS配置 CORS_ORIGINS: "http://localhost:3000,http://localhost:8080,http://localhost:5173" depends_on: mongodb: condition: service_healthy redis: condition: service_healthy networks: - quantscope-network healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/api/health"] interval: 30s timeout: 10s retries: 3 start_period: 60s restart: unless-stopped logging: driver: "json-file" options: max-size: "100m" max-file: "3" # Vue 3 前端服务 frontend: build: context: . dockerfile: Dockerfile.frontend image: quantscope-frontend:v1.0.0 container_name: quantscope-frontend ports: - "3000:80" environment: TZ: "Asia/Shanghai" # 后端API地址 VITE_API_BASE_URL: "http://localhost:8000" depends_on: backend: condition: service_healthy networks: - quantscope-network healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://127.0.0.1"] interval: 30s timeout: 10s retries: 3 start_period: 30s restart: unless-stopped logging: driver: "json-file" options: max-size: "100m" max-file: "3" # MongoDB 数据库服务 mongodb: image: mongo:4.4 container_name: quantscope-mongodb restart: unless-stopped ports: - "27017:27017" environment: MONGO_INITDB_ROOT_USERNAME: admin MONGO_INITDB_ROOT_PASSWORD: tradingagents123 MONGO_INITDB_DATABASE: tradingagents TZ: "Asia/Shanghai" volumes: - mongodb_data:/data/db - ./scripts/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro networks: - quantscope-network healthcheck: test: echo 'db.runCommand("ping").ok' | mongo localhost:27017/test --quiet interval: 30s timeout: 10s retries: 3 start_period: 40s logging: driver: "json-file" options: max-size: "50m" max-file: "2" # Redis 缓存服务 redis: image: redis:7-alpine container_name: quantscope-redis restart: unless-stopped ports: - "6379:6379" environment: TZ: "Asia/Shanghai" command: redis-server --appendonly yes --requirepass tradingagents123 volumes: - redis_data:/data networks: - quantscope-network healthcheck: test: ["CMD", "redis-cli", "--raw", "incr", "ping"] interval: 30s timeout: 10s retries: 3 start_period: 30s logging: driver: "json-file" options: max-size: "50m" max-file: "2" # Redis Commander 管理界面(可选) redis-commander: image: ghcr.io/joeferner/redis-commander:latest container_name: quantscope-redis-commander restart: unless-stopped ports: - "8081:8081" environment: - REDIS_HOSTS=local:redis:6379:0:tradingagents123 networks: - quantscope-network depends_on: redis: condition: service_healthy healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8081"] interval: 30s timeout: 10s retries: 3 start_period: 30s profiles: - management # Mongo Express 管理界面(可选) mongo-express: image: mongo-express:latest container_name: quantscope-mongo-express restart: unless-stopped ports: - "8082:8081" environment: ME_CONFIG_MONGODB_ADMINUSERNAME: admin ME_CONFIG_MONGODB_ADMINPASSWORD: tradingagents123 ME_CONFIG_MONGODB_URL: mongodb://admin:tradingagents123@mongodb:27017/ ME_CONFIG_BASICAUTH_USERNAME: admin ME_CONFIG_BASICAUTH_PASSWORD: tradingagents123 networks: - quantscope-network depends_on: mongodb: condition: service_healthy profiles: - management # 数据卷定义 volumes: mongodb_data: driver: local name: quantscope_mongodb_data redis_data: driver: local name: quantscope_redis_data networks: quantscope-network: driver: bridge name: quantscope-network