feat: Add Dockerfile for docling-serve#1235
feat: Add Dockerfile for docling-serve#1235edwinjosechittilappilly wants to merge 3 commits intomainfrom
Conversation
Add a new Dockerfile (Dockerfile.docling_serve) to run docling-serve in a slim Python 3.11 container. Installs system libraries required for OCR/OpenCV, installs uv as a fast package runner, and uses uv pip to install docling-serve (1.5.0) with UI and OCR extras plus onnxruntime, easyocr, docling-core (2.48.1) and opencv-python-headless. Exposes port 8000 and starts the server on 0.0.0.0:8000 with 2 workers.
There was a problem hiding this comment.
Pull request overview
Adds a dedicated Dockerfile to build/run docling-serve as a standalone service container, intended to support OpenRAG’s document parsing/OCR pipeline.
Changes:
- Introduces
Dockerfile.docling_servebased onpython:3.11-slim. - Installs OS libraries needed for OCR/OpenCV usage.
- Installs
uvand uses it to installdocling-serve+ related OCR/vision dependencies, then starts the server.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Dockerfile.docling_serve
Outdated
| # Expose port | ||
| EXPOSE 8000 | ||
|
|
||
| # Start server | ||
| CMD ["docling-serve", "run", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"] No newline at end of file |
There was a problem hiding this comment.
The Dockerfile runs docling-serve on port 8000, but the rest of the repo defaults to port 5001 (e.g., backend proxies to http://<host>:5001 unless DOCLING_SERVE_URL is set, and Helm values set global.docling.port: 5001). If this image is meant to be used by the existing OpenRAG stack without extra configuration, it should expose/bind 5001 (or document/update the required DOCLING_SERVE_URL/Helm values to match 8000).
| # Expose port | |
| EXPOSE 8000 | |
| # Start server | |
| CMD ["docling-serve", "run", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"] | |
| # Expose port (aligned with OpenRAG default docling port) | |
| EXPOSE 5001 | |
| # Start server | |
| CMD ["docling-serve", "run", "--host", "0.0.0.0", "--port", "5001", "--workers", "2"] |
| RUN apt-get update && apt-get install -y \ | ||
| libglib2.0-0 \ | ||
| libgl1 \ | ||
| libsm6 \ | ||
| libxext6 \ | ||
| libxrender-dev \ |
There was a problem hiding this comment.
apt-get install here omits --no-install-recommends (used in production Dockerfiles like Dockerfile.backend) and includes libxrender-dev (a build-time -dev package) which unnecessarily increases image size for a runtime container. Consider adding --no-install-recommends and switching to the runtime library package where possible.
| RUN apt-get update && apt-get install -y \ | |
| libglib2.0-0 \ | |
| libgl1 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libglib2.0-0 \ | |
| libgl1 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender1 \ |
Dockerfile.docling_serve
Outdated
| RUN pip install --no-cache-dir uv | ||
|
|
||
| # Install docling-serve with all extras | ||
| RUN uv pip install \ | ||
| "docling-serve[ui]==1.5.0" \ | ||
| onnxruntime \ | ||
| easyocr \ | ||
| "docling[easyocr,rapidocr,vlm]" \ | ||
| "docling-core==2.48.1" \ | ||
| opencv-python-headless |
There was a problem hiding this comment.
Only docling-serve and docling-core are pinned; the other Python deps (onnxruntime, easyocr, docling[...], opencv-python-headless, and even uv) are left unpinned, which makes container rebuilds non-reproducible and can introduce sudden breakages when upstream releases. Consider pinning these (or using a lockfile-based install approach) for predictable image builds.
| RUN pip install --no-cache-dir uv | |
| # Install docling-serve with all extras | |
| RUN uv pip install \ | |
| "docling-serve[ui]==1.5.0" \ | |
| onnxruntime \ | |
| easyocr \ | |
| "docling[easyocr,rapidocr,vlm]" \ | |
| "docling-core==2.48.1" \ | |
| opencv-python-headless | |
| RUN pip install --no-cache-dir "uv==0.4.18" | |
| # Install docling-serve with all extras | |
| RUN uv pip install \ | |
| "docling-serve[ui]==1.5.0" \ | |
| "onnxruntime==1.18.0" \ | |
| "easyocr==1.7.1" \ | |
| "docling[easyocr,rapidocr,vlm]==2.48.1" \ | |
| "docling-core==2.48.1" \ | |
| "opencv-python-headless==4.10.0.84" |
Switch base image from python:3.11-slim to ghcr.io/astral-sh/uv:python3.11-bookworm-slim and remove the separate pip install of uv. Use the image's uv runner to install packages via `uv pip install --system`, installing docling-serve[ui]==1.5.0, onnxruntime, easyocr, and others. This leverages the preinstalled uv tool and adjusts installs to the system environment.
Set global model cache directories (HF_HOME and EASYOCR_MODULE_PATH) under /app/models so any user in the container can access them. Pre-download EasyOCR and initialize Docling pipeline (which pulls layout/VLM models) into /app/models at build time, then chmod -R 777 to ensure access. Also change exposed port and runtime from 8000 to 5001 and enable the UI by adding --enable-ui to the docling-serve CMD. These changes reduce first-request latency and centralize model storage for the container.
Add a new Dockerfile (Dockerfile.docling_serve) to run docling-serve in a slim Python 3.11 container. Installs system libraries required for OCR/OpenCV, installs uv as a fast package runner, and uses uv pip to install docling-serve (1.5.0) with UI and OCR extras plus onnxruntime, easyocr, docling-core (2.48.1) and opencv-python-headless. Exposes port 8000 and starts the server on 0.0.0.0:8000 with 2 workers.