fix: 調整 Dockerfile 中 APT 重試機制與安裝步驟,簡化命令格式

This commit is contained in:
Your Name 2026-01-22 22:18:41 +08:00
parent a9867ee97c
commit 566ee48bfe

View file

@ -361,15 +361,15 @@ RUN set -eux && \
echo "📥 [1/5] 下載 DocLayout-YOLO ONNX 模型..." && \
mkdir -p /models/pdfmathtranslate && \
python3 -c " \
import os; \
os.environ['HF_HUB_DISABLE_PROGRESS_BARS'] = '0'; \
from huggingface_hub import snapshot_download; \
snapshot_download( \
import os; \
os.environ['HF_HUB_DISABLE_PROGRESS_BARS'] = '0'; \
from huggingface_hub import snapshot_download; \
snapshot_download( \
repo_id='wybxc/DocLayout-YOLO-DocStructBench-onnx', \
local_dir='/models/pdfmathtranslate', \
allow_patterns=['*.onnx'], \
local_dir_use_symlinks=False \
)" && \
)" && \
echo "✅ DocLayout-YOLO ONNX 下載完成" && \
ls -lh /models/pdfmathtranslate/*.onnx 2>/dev/null || ls -lh /models/pdfmathtranslate/ && \
\
@ -437,23 +437,23 @@ snapshot_download( \
if command -v mineru >/dev/null 2>&1; then \
echo "使用顯式 Python 腳本下載 MinerU 模型..."; \
python3 -c " \
import os, json; \
os.environ['HF_HUB_DISABLE_PROGRESS_BARS'] = '0'; \
from huggingface_hub import snapshot_download; \
# PDF-Extract-Kit-1.0 Pipeline 模型
models_dir = '/models/mineru'; \
print('下載 PDF-Extract-Kit-1.0 模型...'); \
try: \
import os, json; \
os.environ['HF_HUB_DISABLE_PROGRESS_BARS'] = '0'; \
from huggingface_hub import snapshot_download; \
# PDF-Extract-Kit-1.0 Pipeline 模型
models_dir = '/models/mineru'; \
print('下載 PDF-Extract-Kit-1.0 模型...'); \
try: \
snapshot_download( \
repo_id='opendatalab/PDF-Extract-Kit-1.0', \
local_dir=os.path.join(models_dir, 'PDF-Extract-Kit-1.0'), \
local_dir_use_symlinks=False \
); \
print('✅ PDF-Extract-Kit-1.0 下載完成'); \
except Exception as e: \
except Exception as e: \
print(f'⚠️ PDF-Extract-Kit-1.0 下載失敗: {e}'); \
# 建立 mineru.json 設定檔
config = { \
# 建立 mineru.json 設定檔
config = { \
'models-dir': { \
'pipeline': os.path.join(models_dir, 'PDF-Extract-Kit-1.0'), \
'vlm': '' \
@ -463,11 +463,11 @@ config = { \
'display': {'left': '\$\$', 'right': '\$\$'}, \
'inline': {'left': '\$', 'right': '\$'} \
} \
}; \
with open('/root/mineru.json', 'w') as f: \
}; \
with open('/root/mineru.json', 'w') as f: \
json.dump(config, f, indent=2); \
print('✅ mineru.json 已建立'); \
" || echo "⚠️ MinerU 模型下載失敗,將在 runtime 時嘗試下載"; \
print('✅ mineru.json 已建立'); \
" || echo "⚠️ MinerU 模型下載失敗,將在 runtime 時嘗試下載"; \
else \
echo "⚠️ mineru 命令不可用,跳過模型下載"; \
echo '{"models-dir":{"pipeline":"","vlm":""},"model-source":"huggingface","latex-delimiter-config":{"display":{"left":"$$","right":"$$"},"inline":{"left":"$","right":"$"}}}' > /root/mineru.json; \