version: '3.8' services: # Nginx 负载均衡器 nginx: image: nginx:alpine container_name: novalon-nginx ports: - "80:80" - "443:443" volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro - ./ssl:/etc/nginx/ssl:ro depends_on: - app1 - app2 - app3 restart: unless-stopped networks: - novalon-network healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/health"] interval: 30s timeout: 10s retries: 3 # 应用实例 1 app1: build: context: . dockerfile: Dockerfile container_name: novalon-app-1 environment: - NODE_ENV=production - PORT=3001 env_file: - .env.production volumes: - ./data:/app/data - ./uploads:/app/uploads restart: unless-stopped networks: - novalon-network healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3001/api/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s deploy: resources: limits: cpus: '1.0' memory: 1G reservations: cpus: '0.5' memory: 512M # 应用实例 2 app2: build: context: . dockerfile: Dockerfile container_name: novalon-app-2 environment: - NODE_ENV=production - PORT=3002 env_file: - .env.production volumes: - ./data:/app/data - ./uploads:/app/uploads restart: unless-stopped networks: - novalon-network healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3002/api/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s deploy: resources: limits: cpus: '1.0' memory: 1G reservations: cpus: '0.5' memory: 512M # 应用实例 3 app3: build: context: . dockerfile: Dockerfile container_name: novalon-app-3 environment: - NODE_ENV=production - PORT=3003 env_file: - .env.production volumes: - ./data:/app/data - ./uploads:/app/uploads restart: unless-stopped networks: - novalon-network healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3003/api/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s deploy: resources: limits: cpus: '1.0' memory: 1G reservations: cpus: '0.5' memory: 512M networks: novalon-network: driver: bridge