docker-compose.pdf.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. services:
  2. # 主应用(Web API 服务)- 用于渲染 HTML
  3. app:
  4. build: .
  5. container_name: math_cms_app
  6. ports:
  7. - "8000:8000"
  8. env_file:
  9. - .env
  10. volumes:
  11. - ./storage:/app/storage
  12. - ./.env:/app/.env
  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. # Gotenberg PDF 转换服务(内网访问,不暴露公网端口)
  21. gotenberg:
  22. image: gotenberg/gotenberg:8
  23. container_name: math_cms_gotenberg
  24. restart: unless-stopped
  25. healthcheck:
  26. test: ["CMD-SHELL", "curl -fsS http://localhost:3000/health >/dev/null || exit 1"]
  27. interval: 30s
  28. timeout: 10s
  29. retries: 3
  30. start_period: 20s
  31. deploy:
  32. resources:
  33. limits:
  34. cpus: '2'
  35. memory: 1536M
  36. # PDF Worker 1
  37. pdf-worker-1:
  38. build: .
  39. container_name: pdf_worker_1
  40. command: php artisan queue:work --queue=pdf --sleep=3 --tries=3 --max-time=300 --max-jobs=10
  41. env_file:
  42. - .env
  43. volumes:
  44. - ./storage:/app/storage
  45. - ./.env:/app/.env
  46. restart: unless-stopped
  47. stop_grace_period: 120s
  48. depends_on:
  49. app:
  50. condition: service_healthy
  51. gotenberg:
  52. condition: service_healthy
  53. healthcheck:
  54. test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
  55. interval: 30s
  56. timeout: 10s
  57. retries: 3
  58. start_period: 10s
  59. deploy:
  60. resources:
  61. limits:
  62. cpus: '1'
  63. memory: 1536M
  64. # PDF Worker 2
  65. pdf-worker-2:
  66. build: .
  67. container_name: pdf_worker_2
  68. command: php artisan queue:work --queue=pdf --sleep=3 --tries=3 --max-time=300 --max-jobs=10
  69. env_file:
  70. - .env
  71. volumes:
  72. - ./storage:/app/storage
  73. - ./.env:/app/.env
  74. restart: unless-stopped
  75. stop_grace_period: 120s
  76. depends_on:
  77. app:
  78. condition: service_healthy
  79. gotenberg:
  80. condition: service_healthy
  81. healthcheck:
  82. test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
  83. interval: 30s
  84. timeout: 10s
  85. retries: 3
  86. start_period: 10s
  87. deploy:
  88. resources:
  89. limits:
  90. cpus: '1'
  91. memory: 1536M
  92. # PDF Worker 3
  93. pdf-worker-3:
  94. build: .
  95. container_name: pdf_worker_3
  96. command: php artisan queue:work --queue=pdf --sleep=3 --tries=3 --max-time=300 --max-jobs=10
  97. env_file:
  98. - .env
  99. volumes:
  100. - ./storage:/app/storage
  101. - ./.env:/app/.env
  102. restart: unless-stopped
  103. stop_grace_period: 120s
  104. depends_on:
  105. app:
  106. condition: service_healthy
  107. gotenberg:
  108. condition: service_healthy
  109. healthcheck:
  110. test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
  111. interval: 30s
  112. timeout: 10s
  113. retries: 3
  114. start_period: 10s
  115. deploy:
  116. resources:
  117. limits:
  118. cpus: '1'
  119. memory: 1536M
  120. # PDF Worker 4
  121. pdf-worker-4:
  122. build: .
  123. container_name: pdf_worker_4
  124. command: php artisan queue:work --queue=pdf --sleep=3 --tries=3 --max-time=300 --max-jobs=10
  125. env_file:
  126. - .env
  127. volumes:
  128. - ./storage:/app/storage
  129. - ./.env:/app/.env
  130. restart: unless-stopped
  131. stop_grace_period: 120s
  132. depends_on:
  133. app:
  134. condition: service_healthy
  135. gotenberg:
  136. condition: service_healthy
  137. healthcheck:
  138. test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
  139. interval: 30s
  140. timeout: 10s
  141. retries: 3
  142. start_period: 10s
  143. deploy:
  144. resources:
  145. limits:
  146. cpus: '1'
  147. memory: 1536M
  148. networks:
  149. default:
  150. driver: bridge