Skip to content

feat: Add Dockerfile for docling-serve#1235

Draft
edwinjosechittilappilly wants to merge 3 commits intomainfrom
docling-serve-image
Draft

feat: Add Dockerfile for docling-serve#1235
edwinjosechittilappilly wants to merge 3 commits intomainfrom
docling-serve-image

Conversation

@edwinjosechittilappilly
Copy link
Collaborator

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.

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.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_serve based on python:3.11-slim.
  • Installs OS libraries needed for OCR/OpenCV usage.
  • Installs uv and uses it to install docling-serve + related OCR/vision dependencies, then starts the server.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +26 to +30
# 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
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
# 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"]

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +11
RUN apt-get update && apt-get install -y \
libglib2.0-0 \
libgl1 \
libsm6 \
libxext6 \
libxrender-dev \
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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 \

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +24
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
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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"

Copilot uses AI. Check for mistakes.
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.
@github-actions github-actions bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Mar 24, 2026
@edwinjosechittilappilly edwinjosechittilappilly marked this pull request as draft March 24, 2026 08:13
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.
@github-actions github-actions bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker enhancement 🔵 New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants