Docker Deployment
Official Docker images built on the Rust core with Debian 13 (Trixie). Each image supports three execution modes: API server (default), command-line tool, and MCP server.
Quick Start
Section titled “Quick Start”Pull and Run
Section titled “Pull and Run”# Start API server (default mode)docker run -p 8000:8000 ghcr.io/xberg-io/xberg:latest
# Test the APIcurl -F "files=@document.pdf" http://localhost:8000/extract# Extract a single filedocker run -v $(pwd):/data ghcr.io/xberg-io/xberg:latest \ extract /data/document.pdf
# Batch process multiple filesdocker run -v $(pwd):/data ghcr.io/xberg-io/xberg:latest \ batch /data/*.pdf --output-format json
# Detect MIME typedocker run -v $(pwd):/data ghcr.io/xberg-io/xberg:latest \ detect /data/unknown-file.bin# Start MCP serverdocker run ghcr.io/xberg-io/xberg:latest mcpPull Image
Section titled “Pull Image”docker pull ghcr.io/xberg-io/xberg:coredocker pull ghcr.io/xberg-io/xberg:latestImage Variants
Section titled “Image Variants”| Core | Full | |
|---|---|---|
| Image | ghcr.io/xberg-io/xberg:core |
ghcr.io/xberg-io/xberg:latest |
| Size | ~1.0–1.3 GB | ~1.5–2.1 GB |
| Tesseract OCR | 12 languages | 12 languages |
| Modern Office | DOCX, PPTX, XLSX | DOCX, PPTX, XLSX |
| Legacy Office | DOC, PPT, XLS (native OLE/CFB) | DOC, PPT, XLS (native OLE/CFB) |
| Startup | ~1s | ~1s |
Core is optimized for production deployments where image size matters. Both images support all major formats — choose based on deployment constraints.
All images include: Tesseract OCR (eng, spa, fra, deu, ita, por, chi-sim, chi-tra, jpn, ara, rus, hin), PDF (pdf_oxide), images, HTML, email, and archives.
Execution Modes
Section titled “Execution Modes”API Server (Default)
Section titled “API Server (Default)”docker run -p 8000:8000 ghcr.io/xberg-io/xberg:latest
# Custom port and CORSdocker run -p 9000:9000 \ -e XBERG_CORS_ORIGINS="https://myapp.com" \ ghcr.io/xberg-io/xberg:latest \ serve --host 0.0.0.0 --port 9000
# With config filedocker run -p 8000:8000 \ -v $(pwd)/xberg.toml:/config/xberg.toml \ ghcr.io/xberg-io/xberg:latest \ serve --config /config/xberg.tomlSee API Server Guide for endpoint documentation.
CLI Mode
Section titled “CLI Mode”# Extract a filedocker run -v $(pwd):/data ghcr.io/xberg-io/xberg:latest \ extract /data/document.pdf
# Extract with OCRdocker run -v $(pwd):/data ghcr.io/xberg-io/xberg:latest \ extract /data/scanned.pdf --ocr true
# Batch processingdocker run -v $(pwd):/data ghcr.io/xberg-io/xberg:latest \ batch /data/*.pdf --format json
# MIME detectiondocker run -v $(pwd):/data ghcr.io/xberg-io/xberg:latest \ detect /data/unknown-file.binMCP Server
Section titled “MCP Server”docker run ghcr.io/xberg-io/xberg:latest mcp
# With configdocker run \ -v $(pwd)/xberg.toml:/config/xberg.toml \ ghcr.io/xberg-io/xberg:latest \ mcp --config /config/xberg.tomlSee API Server Guide - MCP Section for integration details.
Environment Variables
Section titled “Environment Variables”| Variable | Default | Description |
|---|---|---|
XBERG_MAX_REQUEST_BODY_BYTES |
104857600 |
Max request body size in bytes |
XBERG_MAX_MULTIPART_FIELD_BYTES |
104857600 |
Max multipart field (upload) size in bytes |
XBERG_CORS_ORIGINS |
* |
Comma-separated allowed origins |
RUST_LOG |
info |
Log level: error, warn, info, debug, trace |
XBERG_CACHE_DIR |
/app/.xberg |
Cache directory (set explicitly in Docker; outside containers defaults to platform global cache) |
HF_HOME |
/app/.xberg/huggingface |
HuggingFace model cache |
Host and port are set via CLI args: serve --host 0.0.0.0 --port 8000.
Volume Mounts
Section titled “Volume Mounts”# Cache persistence (embedding models, OCR cache)docker run -p 8000:8000 \ -v xberg-cache:/app/.xberg \ ghcr.io/xberg-io/xberg:latest
# Config filedocker run -p 8000:8000 \ -v $(pwd)/xberg.toml:/config/xberg.toml \ ghcr.io/xberg-io/xberg:latest \ serve --config /config/xberg.toml
# Documents (read-only)docker run -v $(pwd)/documents:/data:ro \ ghcr.io/xberg-io/xberg:latest \ extract /data/document.pdfDocker Compose
Section titled “Docker Compose”services: xberg-api: image: ghcr.io/xberg-io/xberg:latest ports: - "8000:8000" environment: - XBERG_CORS_ORIGINS=https://myapp.com - XBERG_MAX_REQUEST_BODY_BYTES=524288000 - RUST_LOG=info volumes: - ./config:/config - cache-data:/app/.xberg command: serve --host 0.0.0.0 --port 8000 --config /config/xberg.toml restart: unless-stopped healthcheck: test: ["CMD", "xberg", "--version"] interval: 30s timeout: 10s retries: 3 start_period: 5s
volumes: cache-data:Security
Section titled “Security”Images run as non-root user xberg (UID 1000). For hardened deployments:
docker run --security-opt no-new-privileges \ --read-only \ --tmpfs /tmp \ -p 8000:8000 \ ghcr.io/xberg-io/xberg:latestEnsure mounted volumes have correct permissions:
chown -R 1000:1000 /path/to/mounted/directoryResource Allocation
Section titled “Resource Allocation”| Workload | Memory | CPU | Notes |
|---|---|---|---|
| Light | 512 MB | 0.5 cores | Small documents, low concurrency |
| Medium | 1 GB | 1 core | Typical documents, moderate concurrency |
| Heavy | 2 GB+ | 2+ cores | Large documents, OCR, high concurrency |
docker run -p 8000:8000 --memory=1g --cpus=1 \ ghcr.io/xberg-io/xberg:latestBuilding Custom Images
Section titled “Building Custom Images”docker build -f docker/Dockerfile.core -t xberg:core .docker build -f docker/Dockerfile.full -t xberg:full .FROM ghcr.io/xberg-io/xberg:latest
USER rootRUN apt-get update && \ apt-get install -y --no-install-recommends your-package-here && \ apt-get clean && rm -rf /var/lib/apt/lists/*
USER xbergCOPY xberg.toml /app/xberg.tomlCMD ["serve", "--config", "/app/xberg.toml"]Other Image Variants
Section titled “Other Image Variants”The published Core and Full images cover most use cases. For specialized needs, the docker/ directory has additional Dockerfiles:
| Dockerfile | What it builds |
|---|---|
Dockerfile.cli |
Minimal image with just the xberg binary — good for CI pipelines and batch jobs |
Dockerfile.musl-build |
Fully static Linux binaries via MUSL — runs on any distro, no dynamic libs |
Dockerfile.musl-ffi |
Static C FFI library for language bindings (Go, Ruby, PHP, Elixir) |
Dockerfile.musl-rustler |
MUSL-based Rustler NIF for Elixir |
CLI Image
Section titled “CLI Image”A stripped-down image with only the CLI binary. No server, no API — just extraction:
docker build -f docker/Dockerfile.cli -t xberg-cli .
docker run -v $(pwd):/data xberg-cli extract /data/document.pdfdocker run -v $(pwd):/data xberg-cli batch /data/*.pdf --format jsondocker run -v $(pwd):/data xberg-cli detect /data/unknown-file.binMUSL Static Builds
Section titled “MUSL Static Builds”These produce binaries with zero dynamic library dependencies. A single file that runs on any Linux — Alpine, scratch containers, bare EC2 instances, whatever.
docker build -f docker/Dockerfile.musl-build -t xberg-musl-build .docker build -f docker/Dockerfile.musl-ffi -t xberg-musl-ffi .The FFI variant builds a shared library used by the Go, Ruby, PHP, and Elixir bindings for portable cross-platform distribution.
Troubleshooting
Section titled “Troubleshooting”Next Steps
Section titled “Next Steps”- Kubernetes Deployment — deploy on a cluster with the Helm chart
- API Server Guide — endpoint documentation
- Configuration — all configuration options