| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- services:
- # 主应用(Web API 服务)
- app:
- build: .
- container_name: math_cms_app
- command: php artisan serve --host=0.0.0.0 --port=8000
- ports:
- - "5019:8000"
- env_file:
- - .env
- volumes:
- - ./storage:/app/storage # 日志 + 临时文件 + OCR上传
- - ./.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
- # 队列 Worker(通用任务队列)
- queue:
- build: .
- container_name: math_cms_queue
- command: php artisan queue:work --sleep=3 --tries=3 --max-time=3600
- env_file:
- - .env
- volumes:
- - ./storage:/app/storage
- - ./.env:/app/.env
- restart: unless-stopped
- deploy:
- resources:
- limits:
- cpus: '1'
- memory: 512M
- # PDF 生成专用 Worker(资源隔离,防止 Chrome 吃满 CPU)
- pdf-worker:
- build: .
- container_name: math_cms_pdf
- command: php artisan queue:work --queue=pdf --sleep=3 --tries=2 --max-time=300 --max-jobs=10
- env_file:
- - .env
- volumes:
- - ./storage:/app/storage
- - ./.env:/app/.env
- restart: unless-stopped
- deploy:
- resources:
- limits:
- cpus: '2'
- memory: 2G
- networks:
- default:
- driver: bridge
|