version: '3.8' services: backend: build: context: ./backend dockerfile: Dockerfile image: wanwanyun-backend container_name: wanwanyun-backend restart: always ports: - "40001:40001" volumes: - ./backend:/app - /app/node_modules - ./upload-tool:/upload-tool - ./storage:/app/storage # 本地存储卷 environment: - NODE_ENV=production - STORAGE_ROOT=/app/storage # 存储根目录(不硬编码) networks: - wanwanyun-network frontend: image: nginx:alpine container_name: wanwanyun-frontend restart: always ports: - "8080:80" - "8443:443" volumes: - ./frontend:/usr/share/nginx/html - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf - ./certbot/conf:/etc/letsencrypt - ./certbot/www:/var/www/certbot depends_on: - backend networks: - wanwanyun-network command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'" certbot: image: certbot/certbot container_name: wanwanyun-certbot restart: unless-stopped volumes: - ./certbot/conf:/etc/letsencrypt - ./certbot/www:/var/www/certbot entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'" networks: wanwanyun-network: driver: bridge