# 智能项目定价模型 - 生产环境 Docker Compose 配置 # 域名: pricing.zhicheng.ireborn.com.cn name: pricing-model-prod services: # ============ 前端服务 ============ pricing-frontend-prod: build: context: ./前端应用 dockerfile: Dockerfile args: - VITE_API_BASE_URL=https://pricing-api.zhicheng.ireborn.com.cn/api/v1 container_name: pricing-frontend-prod restart: unless-stopped labels: - "traefik.enable=true" - "traefik.http.routers.pricing-frontend-prod.rule=Host(`pricing.zhicheng.ireborn.com.cn`)" - "traefik.http.routers.pricing-frontend-prod.entrypoints=websecure" - "traefik.http.routers.pricing-frontend-prod.tls=true" - "traefik.http.routers.pricing-frontend-prod.tls.certresolver=letsencrypt" - "traefik.http.services.pricing-frontend-prod.loadbalancer.server.port=80" networks: - pricing_network_prod - traefik_network healthcheck: test: ["CMD", "curl", "-f", "http://localhost/health"] interval: 30s timeout: 10s retries: 3 start_period: 10s logging: driver: "json-file" options: max-size: "10m" max-file: "3" deploy: resources: limits: cpus: '0.5' memory: 256M reservations: cpus: '0.1' memory: 64M # ============ 后端服务 ============ pricing-backend-prod: build: context: ./后端服务 dockerfile: Dockerfile container_name: pricing-backend-prod restart: unless-stopped env_file: - .env environment: - DATABASE_URL=mysql+aiomysql://pricing_user:${MYSQL_PASSWORD}@pricing-mysql-prod:3306/pricing_model_prod?charset=utf8mb4 - PORTAL_CONFIG_API=${PORTAL_CONFIG_API} - APP_ENV=production - DEBUG=false - SECRET_KEY=${SECRET_KEY} - CORS_ORIGINS=["https://pricing.zhicheng.ireborn.com.cn"] labels: - "traefik.enable=true" - "traefik.http.routers.pricing-backend-prod.rule=Host(`pricing-api.zhicheng.ireborn.com.cn`)" - "traefik.http.routers.pricing-backend-prod.entrypoints=websecure" - "traefik.http.routers.pricing-backend-prod.tls=true" - "traefik.http.routers.pricing-backend-prod.tls.certresolver=letsencrypt" - "traefik.http.services.pricing-backend-prod.loadbalancer.server.port=8000" depends_on: pricing-mysql-prod: condition: service_healthy networks: - pricing_network_prod - traefik_network - scrm_network - ai_strategy_network healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s timeout: 10s retries: 3 start_period: 30s logging: driver: "json-file" options: max-size: "10m" max-file: "3" deploy: resources: limits: cpus: '1' memory: 512M reservations: cpus: '0.25' memory: 128M # ============ 数据库服务 ============ pricing-mysql-prod: image: mysql:8.0.36 container_name: pricing-mysql-prod restart: unless-stopped command: - --character-set-server=utf8mb4 - --collation-server=utf8mb4_unicode_ci - --default-time-zone=+08:00 environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_DATABASE: pricing_model_prod MYSQL_USER: pricing_user MYSQL_PASSWORD: ${MYSQL_PASSWORD} volumes: - pricing_mysql_data_prod:/var/lib/mysql - ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro networks: - pricing_network_prod healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"] interval: 30s timeout: 10s retries: 3 start_period: 60s logging: driver: "json-file" options: max-size: "10m" max-file: "3" deploy: resources: limits: cpus: '1' memory: 1G reservations: cpus: '0.25' memory: 256M # ============ 网络配置 ============ networks: pricing_network_prod: driver: bridge name: pricing_network_prod traefik_network: external: true name: traefik_network scrm_network: external: true name: scrm_network ai_strategy_network: external: true name: ai_ai-strategy-network # ============ 数据卷 ============ volumes: pricing_mysql_data_prod: name: pricing_mysql_data_prod