docker-compose.pdf.yml 3.8 KB

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