version: '3.8' services: rag-service: build: context: .. dockerfile: deploy/Dockerfile container_name: rag-service env_file: - ../.env ports: - "5001:5001" volumes: # 数据目录 - ../.data:/app/.data - ../documents:/app/documents - ../models:/app/models - ../data:/app/data # 源码挂载(git pull 后重启即生效,无需重建镜像) - ../api:/app/api - ../core:/app/core - ../knowledge:/app/knowledge - ../services:/app/services - ../parsers:/app/parsers - ../repositories:/app/repositories - ../storage:/app/storage - ../auth:/app/auth - ../config:/app/config - ../exam_pkg:/app/exam_pkg - ../deploy/wsgi.py:/app/deploy/wsgi.py - ../deploy/gunicorn.conf.py:/app/deploy/gunicorn.conf.py - ../config.py:/app/config.py - ../main.py:/app/main.py - ../requirements.txt:/app/requirements.txt - ../requirements-prod.txt:/app/requirements-prod.txt environment: - APP_ENV=prod restart: unless-stopped # 资源限制:Embedding模型加载需要较多内存 shm_size: '256m' # Gunicorn 心跳文件需要 deploy: resources: limits: memory: 6G reservations: memory: 2G healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:5001/health || exit 1"] interval: 30s timeout: 10s retries: 3 start_period: 60s # 给启动和模型加载留出时间