version: '3.8' services: # 开心APP前端服务 emotion-museum-web: build: context: . dockerfile: Dockerfile target: production container_name: emotion-museum-web ports: - "3000:80" environment: - NODE_ENV=production volumes: # 如果需要挂载配置文件 - ./nginx.conf:/etc/nginx/nginx.conf:ro networks: - emotion-museum-network restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s labels: - "traefik.enable=true" - "traefik.http.routers.emotion-web.rule=Host(`localhost`)" - "traefik.http.services.emotion-web.loadbalancer.server.port=80" # 开发模式服务(可选) emotion-museum-web-dev: image: node:18-alpine container_name: emotion-museum-web-dev working_dir: /app ports: - "3001:3000" environment: - NODE_ENV=development volumes: - .:/app - /app/node_modules command: sh -c "npm install && npm run dev" networks: - emotion-museum-network profiles: - dev networks: emotion-museum-network: driver: bridge name: emotion-museum-network volumes: node_modules: