Docker Build Configuration#
RAGFlow ships two distinct Docker build strategies: a three-stage Dockerfile for the main application and a single-stage Dockerfile_deepdoc_oss for the standalone DeepDoc microservice.
Main Application: Three-Stage Dockerfile#
The main Dockerfile uses a three-stage pattern:
| Stage | FROM / name | Purpose |
|---|---|---|
base | ubuntu:24.04 AS base | System deps, models, uv, nginx, Chrome |
builder | base AS builder | Python/JS package installation, frontend compile |
production | base AS production | Runtime image; copies artifacts from builder |
base stage (lines 1–183):
- Mounts
infiniflow/ragflow_deps:latest(a pre-built deps image) to copy model files, NLTK data, Tika JARs,uv, Chrome, and arch-specific binaries without pulling them at build time. - Installs system packages (
libglib2.0-0,default-jdk,ghostscript,pandoc,texlive-*, etc.), nginx, and Node.js 20.x. - Runs
uv python install 3.13to install the pinned Python interpreter. - Performs
uname -mguards to select arch-correct binaries (uv, stagehand server, MS SQL ODBC drivermsodbcsql17vsmsodbcsql18,libssl1.1deb) forx86_64vsaarch64.
builder stage (lines 187–243):
- Adds
build-essential,libpython3-dev,libicu-dev,libgbm-devfor C extension compilation — kept out ofbaseto shrink the production image. - Runs
uv sync --python 3.13 --frozenagainst the lockedpyproject.toml/uv.lock, with mirror rewriting for China CI (NEED_MIRROR=1). Always re-fetcheslitellmto avoid stale cached wheels. - Builds the frontend:
npm installthennpm run buildwithVITE_MINIFY=esbuild. - Writes a
VERSIONfile fromgit describe.
production stage (lines 246–287):
- Inherits
base(no build tools). - Copies only the compiled
.venv, application source (api,rag,deepdoc,agent,mcp, etc.), nginx configs, and the builtweb/distfrombuilder. - Entrypoint:
./entrypoint.sh.
The NEED_MIRROR=1 build arg switches APT, PyPI, and npm to Aliyun/Gitee mirrors throughout all stages .
DeepDoc OSS: Single-Stage Dockerfile_deepdoc_oss#
Dockerfile_deepdoc_oss is a minimal ONNX-only image with no torch, no pdfplumber, and no Ascend dependencies:
- Base:
ubuntu:24.04(single stage) - Python: installs
python3.12andpython3.12-venvfrom Ubuntu's apt repos — pinned to 3.12, not 3.13 - Dependencies: a small
pip installoflitserve onnxruntime opencv-python-headless numpy pillow pyclipper python-multipart shapely six huggingface_hub - Stubs: runs
docker_stubs.pyto generate lightweight stub packages so vision modules load without heavy imports - Models: downloaded from HuggingFace (or
hf-mirror.comwithNEED_MIRROR=1) into/app/rag/res/deepdoc - Port: exposes
9390with acurl-based health check - Entrypoint:
python3 deepdoc_server.py --model-dir /app/rag/res/deepdoc
In docker-compose.yml, this image is used by the deepdoc profile service, built from the repo root with dockerfile: Dockerfile_deepdoc_oss .
Python Version Pinning#
Python version is pinned explicitly across multiple config files:
| Scope | File | Constraint |
|---|---|---|
| Main app / SDK / sandbox | pyproject.toml | >=3.13,<3.14 |
| Main app / SDK / sandbox | uv.lock header | ==3.13.* |
| DeepDoc server | deepdoc/server/pyproject.toml | >=3.11,<3.13 |
| Dockerfile (main) | uv python install | 3.13 explicit |
| Dockerfile_deepdoc_oss | apt install python3.12 | 3.12 explicit |
The DeepDoc server excludes Python 3.13 — its pyproject.toml caps at <3.13 — which is why its Dockerfile installs 3.12 from apt rather than using uv.
Docker Compose Profiles#
docker/docker-compose.yml exposes three profiles via ${RAGFLOW_IMAGE} :
| Profile | Service | Notes |
|---|---|---|
cpu | ragflow-cpu | Standard CPU deployment |
gpu | ragflow-gpu | Adds NVIDIA device reservation (driver: nvidia, count: all) |
deepdoc | deepdoc | Runs deepdoc_oss image on port 9390 |
Key Files#
| File | Role |
|---|---|
Dockerfile | Three-stage main image |
Dockerfile_deepdoc_oss | Single-stage DeepDoc OSS image |
docker/docker-compose.yml | Compose profiles (cpu / gpu / deepdoc) |
pyproject.toml | Python 3.13 constraint for main app |
deepdoc/server/pyproject.toml | Python 3.11–3.12 constraint for DeepDoc server |