mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-10 21:10:55 +08:00
Replace the single legacy Dockerfile (rapidocr_api only) with 7 per-engine development images covering all supported inference backends: - onnxruntime-cpu: ONNX Runtime on CPU (python:3.10-slim-bookworm) - onnxruntime-gpu: ONNX Runtime with CUDA (nvidia/cuda:12.4.1) - tensorrt: NVIDIA TensorRT (nvcr.io/nvidia/deepstream:7.0-gc-triton-devel) - paddle: PaddlePaddle CPU - openvino: Intel OpenVINO - pytorch: PyTorch CPU - mnn: Alibaba MNN Infrastructure: - Dockerfile.base: shared foundation for CPU variants - docker-compose.yaml: all 7 services with shared model volume - Makefile: make build-*/test-*/shell-* convenience commands - .dockerignore: excludes .git, models, build artifacts Key design decisions: - PYTHONPATH-based imports (setup.py incompatible with pip editable install) - Named volume (rapidocr-models) for persistent model cache across rebuilds - Source bind-mounted at runtime for live editing - tensorrt pinned to 8.6.x + cuda-python 12.x (matching DeepStream 7.0) All 7 images built and tested with full OCR pipeline inference. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1.4 KiB
Docker
50 lines
1.4 KiB
Docker
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONPATH=/app
|
|
|
|
WORKDIR /app
|
|
|
|
# Install Python 3.10 and system deps
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
software-properties-common \
|
|
&& add-apt-repository ppa:deadsnakes/ppa \
|
|
&& apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
python3.10 \
|
|
python3.10-venv \
|
|
python3.10-dev \
|
|
python3-pip \
|
|
libgl1 \
|
|
libglib2.0-0 \
|
|
libsm6 \
|
|
libxext6 \
|
|
libxrender1 \
|
|
gcc \
|
|
g++ \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Make python3.10 the default
|
|
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && \
|
|
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
|
|
|
|
# Copy and install deps
|
|
COPY python/requirements.txt /tmp/requirements.txt
|
|
|
|
RUN python -m pip install --no-cache-dir --upgrade pip && \
|
|
pip install --no-cache-dir -r /tmp/requirements.txt && \
|
|
pip uninstall -y opencv-python 2>/dev/null; \
|
|
pip install --no-cache-dir opencv-python-headless && \
|
|
pip install --no-cache-dir pytest && \
|
|
rm /tmp/requirements.txt
|
|
|
|
# Install ONNX Runtime GPU
|
|
RUN pip install --no-cache-dir onnxruntime-gpu
|
|
|
|
# Copy source (bind-mounted at runtime for live editing via docker-compose)
|
|
COPY python/ /app/
|
|
|
|
CMD ["bash"]
|