version: '3.8' services: app: image: node:18 container_name: data-collection-app working_dir: /app volumes: # 挂载当前目录到容器的 /app 目录 - .:/app # 使用命名卷存储 node_modules,避免权限问题 - node_modules:/app/node_modules ports: - "3000:3000" environment: - NODE_ENV=production - PORT=3000 command: sh -c "npm install && npm start" restart: unless-stopped networks: - app-network volumes: node_modules: networks: app-network: driver: bridge