services: # SvelteKit 前端服务 web: build: context: ./web dockerfile: Dockerfile container_name: billai-web restart: unless-stopped ports: - "3000:3000" environment: NODE_ENV: production HOST: "0.0.0.0" PORT: "3000" # SSR 服务端请求后端的地址(Docker 内部网络) API_URL: "http://server:8080" depends_on: server: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3000"] interval: 10s timeout: 5s retries: 5 start_period: 15s # Go 后端服务 server: build: context: ./server dockerfile: Dockerfile container_name: billai-server restart: unless-stopped ports: - "8080:8080" environment: ANALYZER_URL: "http://analyzer:8001" ANALYZER_MODE: "http" MONGO_URI: "mongodb://admin:password@mongodb:27017" MONGO_DATABASE: "billai" # 认证配置 JWT_SECRET: "billai-secret-key-2026" TOKEN_EXPIRY: "1" # Token 过期时间(小时) # 管理员账号(如需覆盖配置文件中的用户,取消注释以下配置) ADMIN_USERNAME: "admin" ADMIN_PASSWORD: "admin123" ADMIN_NAME: "管理员" volumes: - ./uploads:/app/uploads - ./server/outputs:/app/outputs depends_on: analyzer: condition: service_healthy mongodb: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 10s timeout: 5s retries: 5 start_period: 10s # Python 分析服务 (FastAPI) analyzer: build: context: ./analyzer dockerfile: Dockerfile container_name: billai-analyzer restart: unless-stopped ports: - "8001:8001" environment: ANALYZER_HOST: "0.0.0.0" ANALYZER_PORT: "8001" volumes: # 共享数据目录,用于访问上传的文件 - ./server/uploads:/app/uploads - ./server/outputs:/app/outputs healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8001/health"] interval: 10s timeout: 5s retries: 5 start_period: 10s mongodb: image: mongo:8.0 container_name: billai-mongodb restart: unless-stopped ports: - "27017:27017" environment: MONGO_INITDB_DATABASE: billai # 如需认证,取消下面两行注释 MONGO_INITDB_ROOT_USERNAME: admin MONGO_INITDB_ROOT_PASSWORD: password volumes: - ./mongodata/db:/data/db - ./mongodata/configdb:/data/configdb healthcheck: test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"] interval: 10s timeout: 5s retries: 5 start_period: 10s networks: default: aliases: - mongo # 可选:MongoDB 可视化管理工具 mongo-express: image: mongo-express:latest container_name: billai-mongo-express restart: unless-stopped ports: - "8083:8081" environment: ME_CONFIG_MONGODB_SERVER: mongodb ME_CONFIG_MONGODB_PORT: 27017 ME_CONFIG_BASICAUTH: "false" # 如启用 MongoDB 认证,取消下面两行注释 ME_CONFIG_MONGODB_ADMINUSERNAME: admin ME_CONFIG_MONGODB_ADMINPASSWORD: password depends_on: mongodb: condition: service_healthy