services: backend: build: context: . dockerfile: backend/Dockerfile volumes: - ./backend:/app/backend - backend_modules:/app/backend/node_modules - ./frontend:/app/frontend:ro - ./backend/novels.db:/app/data/novels.db - ./storage/json/biquge:/app/storage/json/biquge:ro environment: - JWT_SECRET=${JWT_SECRET:?请设置 JWT_SECRET 环境变量} - DB_PATH=/app/data/novels.db - CORS_ORIGIN=${CORS_ORIGIN:-*} - NODE_ENV=production - PORT=8081 healthcheck: test: [ "CMD", "node", "-e", "const http=require('http'); const req=http.get({host:'127.0.0.1', port:8081, path:'/api/health', timeout:3000}, (res)=>{ process.exit(res.statusCode === 200 ? 0 : 1); }); req.on('error', ()=>process.exit(1)); req.on('timeout', ()=>{ req.destroy(); process.exit(1); });" ] start_period: 25s interval: 30s timeout: 5s retries: 3 logging: driver: json-file options: max-size: "10m" max-file: "3" restart: unless-stopped nginx: image: nginx:alpine ports: - "80:80" volumes: - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro depends_on: backend: condition: service_healthy logging: driver: json-file options: max-size: "10m" max-file: "3" restart: unless-stopped volumes: backend_modules: