docker-compose.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. - ./.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. deploy:
  33. resources:
  34. limits:
  35. cpus: '1'
  36. memory: 512M
  37. # PDF 生成专用 Worker(资源隔离,防止 Chrome 吃满 CPU)
  38. pdf-worker:
  39. build: .
  40. container_name: math_cms_pdf
  41. command: php artisan queue:work --queue=pdf --sleep=3 --tries=2 --max-time=300 --max-jobs=10
  42. env_file:
  43. - .env
  44. volumes:
  45. - ./storage:/app/storage
  46. - ./.env:/app/.env
  47. restart: unless-stopped
  48. deploy:
  49. resources:
  50. limits:
  51. cpus: '2'
  52. memory: 2G
  53. networks:
  54. default:
  55. driver: bridge