services: # 开发环境 app-dev: build: context: . target: development ports: - "3000:3000" volumes: - .:/app - /app/node_modules environment: - NODE_ENV=development profiles: - dev # 生产环境 app-prod: build: context: . target: production ports: - "80:80" environment: - NODE_ENV=production restart: unless-stopped profiles: - prod # 使用外部nginx(可选) nginx: image: nginx:alpine ports: - "8080:80" volumes: - ./dist:/usr/share/nginx/html:ro - ./nginx.conf:/etc/nginx/nginx.conf:ro depends_on: - app-prod profiles: - external-nginx