# PP-OCRv5 ONNX 轻量部署(RapidOCR + ONNX Runtime) FROM python:3.10-slim # 安装系统依赖 RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 \ libglib2.0-0 \ libgomp1 \ curl \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # 安装 Python 依赖 COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # 复制代码 COPY app.py . # 预下载 PP-OCRv5 ONNX 模型(避免首次请求慢) RUN python -c "from huggingface_hub import hf_hub_download; hf_hub_download('monkt/paddleocr-onnx', 'detection/v5/det.onnx'); hf_hub_download('monkt/paddleocr-onnx', 'languages/english/rec.onnx'); hf_hub_download('monkt/paddleocr-onnx', 'languages/english/dict.txt'); print('PP-OCRv5 ONNX models downloaded')" EXPOSE 7860 HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ CMD curl -f http://localhost:7860/ || exit 1 CMD ["python", "app.py"]