docker-compose.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. services:
  2. # 主应用(Web API 服务)- 使用 Nginx + PHP-FPM
  3. app:
  4. build: .
  5. container_name: math_cms_app
  6. # 使用 Dockerfile 中的默认 CMD(nginx + php-fpm)
  7. ports:
  8. - "5019:8000"
  9. env_file:
  10. - .env
  11. volumes:
  12. - ./storage:/app/storage # 日志 + 临时文件 + OCR上传
  13. - ./.env:/app/.env # 环境配置文件
  14. restart: unless-stopped
  15. healthcheck:
  16. test: ["CMD-SHELL", "curl -f http://localhost:8000/health || exit 1"]
  17. interval: 30s
  18. timeout: 10s
  19. retries: 3
  20. start_period: 40s
  21. # 队列 Worker(通用任务队列)
  22. queue:
  23. build: .
  24. container_name: math_cms_queue
  25. command: php artisan queue:work --sleep=3 --tries=3 --max-time=3600
  26. env_file:
  27. - .env
  28. volumes:
  29. - ./storage:/app/storage
  30. - ./.env:/app/.env
  31. restart: unless-stopped
  32. # 队列 worker 健康检查:检查进程是否存在
  33. healthcheck:
  34. test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
  35. interval: 30s
  36. timeout: 10s
  37. retries: 3
  38. start_period: 10s
  39. deploy:
  40. resources:
  41. limits:
  42. cpus: '1'
  43. memory: 512M
  44. # PDF 生成专用 Worker(资源隔离,防止 Chrome 吃满 CPU)
  45. pdf-worker:
  46. build: .
  47. container_name: math_cms_pdf
  48. command: php artisan queue:work --queue=pdf --sleep=3 --tries=2 --max-time=300 --max-jobs=10
  49. env_file:
  50. - .env
  51. volumes:
  52. - ./storage:/app/storage
  53. - ./.env:/app/.env
  54. restart: unless-stopped
  55. # PDF worker 健康检查:检查进程是否存在
  56. healthcheck:
  57. test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
  58. interval: 30s
  59. timeout: 10s
  60. retries: 3
  61. start_period: 10s
  62. deploy:
  63. resources:
  64. limits:
  65. cpus: '2'
  66. memory: 2G
  67. networks:
  68. default:
  69. driver: bridge