fix(docling): align volume mount with HF default cache path

Build preloads models to /root/.cache/huggingface (HF default).
Volume must mount there too, not a separate /models path.
Remove HF_HOME env override to keep paths consistent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-07 07:38:28 -08:00
parent 9b357fe01c
commit 15d42315ed
2 changed files with 3 additions and 6 deletions

View File

@ -256,12 +256,10 @@ services:
dockerfile: Dockerfile
container_name: iconsulting-docling
restart: unless-stopped
environment:
HF_HOME: /models/huggingface
ports:
- "3007:3007"
volumes:
- docling_models:/models
- docling_models:/root/.cache/huggingface
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:3007/health')"]
interval: 30s

View File

@ -13,9 +13,8 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY app/ ./app/
COPY scripts/ ./scripts/
# 模型缓存目录(运行时通过 Docker volume 持久化到 /models
# 构建时预下载到镜像默认路径;运行时 HF_HOME=/models/huggingface 由 volume 接管
ENV HF_HOME=/root/.cache/huggingface
# 构建时预下载模型到 /root/.cache/huggingfaceHF 默认路径)
# 运行时通过 Docker volume 持久化该目录,首次启动从镜像初始化 volume
RUN python scripts/preload_models.py || echo "Model preload skipped (will download on first request)"
EXPOSE 3007