services:
# 主应用(Web API 服务)- 用于渲染 HTML
app:
build: .
container_name: math_cms_app
ports:
- "8000:8000"
env_file:
- .env
volumes:
- ./storage:/app/storage
- ./.env:/app/.env
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# PDF Worker 1
pdf-worker-1:
build: .
container_name: pdf_worker_1
command: php artisan queue:work --queue=pdf --sleep=3 --tries=3 --max-time=300 --max-jobs=10
env_file:
- .env
volumes:
- ./storage:/app/storage
- ./.env:/app/.env
restart: unless-stopped
depends_on:
app:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: '1'
memory: 1536M
# PDF Worker 2
pdf-worker-2:
build: .
container_name: pdf_worker_2
command: php artisan queue:work --queue=pdf --sleep=3 --tries=3 --max-time=300 --max-jobs=10
env_file:
- .env
volumes:
- ./storage:/app/storage
- ./.env:/app/.env
restart: unless-stopped
depends_on:
app:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: '1'
memory: 1536M
# PDF Worker 3
pdf-worker-3:
build: .
container_name: pdf_worker_3
command: php artisan queue:work --queue=pdf --sleep=3 --tries=3 --max-time=300 --max-jobs=10
env_file:
- .env
volumes:
- ./storage:/app/storage
- ./.env:/app/.env
restart: unless-stopped
depends_on:
app:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: '1'
memory: 1536M
# PDF Worker 4
pdf-worker-4:
build: .
container_name: pdf_worker_4
command: php artisan queue:work --queue=pdf --sleep=3 --tries=3 --max-time=300 --max-jobs=10
env_file:
- .env
volumes:
- ./storage:/app/storage
- ./.env:/app/.env
restart: unless-stopped
depends_on:
app:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: '1'
memory: 1536M
networks:
default:
driver: bridge