docker-compose.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. services:
  2. # 主应用(Web API 服务)
  3. app:
  4. build: .
  5. container_name: math_cms_app
  6. command: php artisan serve --host=0.0.0.0 --port=8000
  7. ports:
  8. - "5019:8000"
  9. env_file:
  10. - .env
  11. volumes:
  12. - ./storage:/app/storage # 日志 + 临时文件 + OCR上传
  13. restart: unless-stopped
  14. healthcheck:
  15. test: ["CMD-SHELL", "curl -f http://localhost:8000/health || exit 1"]
  16. interval: 30s
  17. timeout: 10s
  18. retries: 3
  19. start_period: 40s
  20. # 队列 Worker(通用任务队列)
  21. queue:
  22. build: .
  23. container_name: math_cms_queue
  24. command: php artisan queue:work --sleep=3 --tries=3 --max-time=3600
  25. env_file:
  26. - .env
  27. volumes:
  28. - ./storage:/app/storage
  29. restart: unless-stopped
  30. deploy:
  31. resources:
  32. limits:
  33. cpus: '1'
  34. memory: 512M
  35. # PDF 生成专用 Worker(资源隔离,防止 Chrome 吃满 CPU)
  36. pdf-worker:
  37. build: .
  38. container_name: math_cms_pdf
  39. command: php artisan queue:work --queue=pdf --sleep=3 --tries=2 --max-time=300 --max-jobs=10
  40. env_file:
  41. - .env
  42. volumes:
  43. - ./storage:/app/storage
  44. restart: unless-stopped
  45. deploy:
  46. resources:
  47. limits:
  48. cpus: '2'
  49. memory: 2G
  50. networks:
  51. default:
  52. driver: bridge