feat(docling): persist model cache via Docker volume
- Add docling_models volume mounted at /models in container - Set HF_HOME=/models/huggingface at runtime (via docker-compose env) - Models download once → persist in volume → survive container rebuilds - Build-time preload uses || to not block build if network unavailable Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
764613bd86
commit
73dee93d19
|
|
@ -256,8 +256,12 @@ services:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: iconsulting-docling
|
container_name: iconsulting-docling
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
HF_HOME: /models/huggingface
|
||||||
ports:
|
ports:
|
||||||
- "3007:3007"
|
- "3007:3007"
|
||||||
|
volumes:
|
||||||
|
- docling_models:/models
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:3007/health')"]
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:3007/health')"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
|
|
@ -478,3 +482,5 @@ volumes:
|
||||||
driver: local
|
driver: local
|
||||||
minio_data:
|
minio_data:
|
||||||
driver: local
|
driver: local
|
||||||
|
docling_models:
|
||||||
|
driver: local
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,10 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||||
COPY app/ ./app/
|
COPY app/ ./app/
|
||||||
COPY scripts/ ./scripts/
|
COPY scripts/ ./scripts/
|
||||||
|
|
||||||
# 构建时预下载模型(实际执行一次 PDF 转换触发 HuggingFace 模型下载)
|
# 模型缓存目录(运行时通过 Docker volume 持久化到 /models)
|
||||||
RUN python scripts/preload_models.py
|
# 构建时预下载到镜像默认路径;运行时 HF_HOME=/models/huggingface 由 volume 接管
|
||||||
|
ENV HF_HOME=/root/.cache/huggingface
|
||||||
|
RUN python scripts/preload_models.py || echo "Model preload skipped (will download on first request)"
|
||||||
|
|
||||||
EXPOSE 3007
|
EXPOSE 3007
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue