Keep .env.example intact.
Copy the template to .env and edit only the copy. The versioned template stays the reference; your file holds local values and secrets. Never commit or publish .env.
The practical configuration guide
109 template settings, grouped exactly as .env.example. Search names and explanations without opening or exposing your local configuration.
# Inbound MCP token:label list (distinct from API token)
MCP_API_TOKENS=<unique-secret>:local-agent
-NoMcp or -Frontend) override environment values for that command.
02 / Shell environment → selected .env fileExported shell variables override .env; .env overrides Compose and application defaults.
03 / Active vs commented native examplesSection 14 lists commented native overrides (optional) that stock Compose does not forward.
The file is a contract between you and the launchers. Three habits keep it safe.
Copy the template to .env and edit only the copy. The versioned template stays the reference; your file holds local values and secrets. Never commit or publish .env.
Each line is NAME=value. No spaces around the equals sign, no comments on a value line that change its meaning, and use a plain-text editor so the file keeps its encoding and its leading dot.
.env is read by the launcher and Compose; it is not documentation for others and not a place for prose. This guide explains every name so the file can stay terse.
The template defaults carry the whole first run. Only the credentials need your decision.
Set OCR_SERVER_API_TOKENS to a strong random secret followed by a label such as :console — the console's API key field takes the secret alone. Set MCP_API_TOKENS to a different secret followed by :local-agent. Set UPSTREAM_CLIENT_TOKEN to a third plain secret, no label: the MCP server presents it to the API, which accepts it automatically.
Everything else stays at the shipped defaults for a first run: ports, budgets, GPU overrides and the storage profile. Reach for them when a real need appears — every name below is documented.
OCR_SERVER_API_TOKENS=<strong-random-secret>:console
MCP_API_TOKENS=<different-secret>:local-agent
UPSTREAM_CLIENT_TOKEN=<third-secret>
Illustrative placeholders — generate real secrets on your own machine and keep them out of chat.
Defaults are a contract. Local credentials are not documentation.
Use .env.example as the versioned reference and .env for local values. Compose reads the selected env file; it does not automatically read the example.
CLI selection overrides shell values, then the selected env file, then the Compose ${VAR:-fallback} — missing and empty values both use the fallback. Inside ocr-api an empty OCR_VL_LANES, OCR_PAGE_PARALLELISM or OCR_LAYOUT_THREADS falls through to the calibrated hardware profile, every other empty value to the built-in default; GPU overrides stay empty for automatic hardware selection.
The native API reads its process environment, not a dotenv file. Native MCP started from a source checkout also reads the repository root .env (the shell still wins); an installed package reads only its process environment. Section 14 entries are commented native examples and are not forwarded by Compose.
The storage profile is off by default. The API runs the same without it — enabling it adds SeaweedFS, a gateway and a one-shot initializer.
Run python scripts/configure_storage.py to activate it. The helper writes into .env — locally, never printed. It always switches on the three activation keys and fills the rest only where empty:
OCR_STORAGE_ENABLED=true, OCR_STORAGE_BROWSER_ENABLED=true, and storage added to COMPOSE_PROFILES.OCR_S3_BUCKET=ocr-outputs, OCR_S3_RETENTION_DAYS=30, OCR_STORAGE_SAVE_PARSED=true, OCR_STORAGE_SAVE_INPUT=false.OCR_S3_* and OCR_SEAWEED_* names in section 13 — generated only where empty.On the next up, startup runs the synchronous bucket and identity initializer before the API. Disabling the profile later excludes it from future start plans; already running storage containers remain until stopped or down.
COMPOSE_PROFILES=…,storage
OCR_STORAGE_ENABLED=true
OCR_STORAGE_BROWSER_ENABLED=true
OCR_S3_BUCKET=ocr-outputs
OCR_S3_RETENTION_DAYS=30
OCR_S3_* / OCR_SEAWEED_* = generated locally
Existing credentials and behaviour values are preserved, the activation keys are always set; secrets are never displayed. Groups 12 and 13 below document every name.
The OCR stack uses distinct labelled credentials for the API and MCP, plus one service token between them.
OCR_SERVER_API_TOKENS holds unique token:label pairs; clients send the token half alone. Empty disables API authentication. Health, enabled docs and frontend assets stay public.
MCP_API_TOKENS holds unique token:label pairs, separate from the API secret. Compose requires credentials even on host loopback.
UPSTREAM_CLIENT_TOKEN is one plain service token. The API accepts it automatically under the label @mcp, so it never goes in the API list. Required when API authentication is on.
The published vLLM port has no configured bearer authentication. The OCR API token does not protect it. Keep loopback publications; CORS is not an access token.
OCR_SERVER_API_TOKENS gates the console and every API call, plus a separate UPSTREAM_CLIENT_TOKEN for the MCP server.MCP_API_TOKENS uses its own token:label list — reusing the API secret blurs two boundaries.127.0.0.1 in Compose, including unauthenticated vLLM docs on OCR_VLLM_DOCS_PORT.OCR_S3_* identities carry least-privilege roles — never share them with the API or MCP secrets.Console / REST → :8020 → OCR_SERVER_API_TOKENS (token:label)
Agent → :8021 → MCP_API_TOKENS (token:label)
MCP → API → UPSTREAM_CLIENT_TOKEN
Host browser → :8081 → no bearer — keep loopback
Archive → :8333 → OCR_S3_* role keys
Each door checks only its own key. The API also accepts the MCP service token, logged as @mcp.
Edits take effect through the launcher, not by saving alone. Three steps keep the change deliberate.
Save .env in your editor, then run verify. It checks the token/storage relationships and Compose security without touching Docker state — fix what it names before applying.
Run from the repository root
pwsh .\stack.ps1 verify
bash stack.sh verify
config prints the resolved Compose configuration with credentials redacted — check the value you changed is the one Compose will see. Shell variables still win over the file.
Run from the repository root
pwsh .\stack.ps1 config
bash stack.sh config
Use up when .env changed — restart reuses the existing container configuration and keeps the old value. Afterwards, check /health for status=healthy and vllm=reachable.
Run from the repository root
pwsh .\stack.ps1 up -Wait
Invoke-RestMethod http://127.0.0.1:8020/health
bash stack.sh up --wait
curl --fail --show-error --silent http://127.0.0.1:8020/health
Active assignments and commented native examples have different effects. Search includes names, defaults and explanations.
109 settings
No settings match. Clear the search or use a variable name.
COMPOSE_PROFILESActive assignment(empty)Empty starts the base stack. The storage profile adds the optional SeaweedFS services and provisioning.
MCP_SERVER_ENABLEDActive assignmenttrueLauncher-only selection. False omits MCP from startup, stops/removes a previously enabled MCP container during up and skips MCP token validation in verify; a direct docker compose up ignores it.
OCR_ARCHIVE_ONLYActive assignmentfalseArchive-only mode: read stored OCR archives with no vllm-paddleocr container and no GPU reservation. The launchers apply it through compose.archive-only.yml (-ArchiveOnly / --archive-only force it for one run): the API answers 503 ocr_disabled_archive_only on /parse, /ocr and /parse/chunks, skips autotune and the vLLM poll, and reports mode=archive_only with vllm=disabled in /health (healthy once the archive bucket probe succeeds); storage, /chunk, RAG refinement and Office previews keep working. Needs OCR_STORAGE_ENABLED and OCR_STORAGE_BROWSER_ENABLED; a direct docker compose up ignores it.
OCR_SERVER_PORTActive assignment8020Host loopback port for the API and console; the API container remains on port 8020.
OCR_VLLM_DOCS_PORTActive assignment8081Host loopback port for the model server API and documentation. It is not protected by the OCR bearer token.
MCP_PORTActive assignment8021MCP listener and published loopback port.
OCR_S3_PORTActive assignment8333Published S3 gateway port, used only by the storage profile.
OCR_STORAGE_CONSOLE_PORTActive assignment23646Published SeaweedFS console port, used only by the storage profile.
OCR_SERVER_API_TOKENSActive assignment(empty)Inbound API and console token:label entries separated by commas; clients and the console's API key field use the token half alone. Tokens and labels must be unique; labels match [A-Za-z0-9._-]+. When set, everything except /, /health, /assets/* and the enabled OpenAPI routes requires the bearer token, including /stats and /metrics. Empty disables API authentication. Replaces the former OCR_SERVER_API_TOKEN, which is now refused. Never put a real token in this guide.
MCP_API_TOKENSActive assignment(empty)Inbound MCP token:label entries separated by commas. Tokens and labels must be unique; use secrets distinct from the API tokens and the service token. Required by Compose MCP: empty fails verify and the container start — start with -NoMcp / --no-mcp or MCP_SERVER_ENABLED=false instead.
UPSTREAM_CLIENT_TOKENActive assignment(empty)Plain MCP-to-API service token, no label. ocr-api accepts it automatically as @mcp, so it must not appear in OCR_SERVER_API_TOKENS. Required when API authentication is on and MCP is enabled; host-side live verifiers send it too. ocr-api ignores it while OCR_SERVER_API_TOKENS is empty.
EXPOSE_OCR_SWAGGERActive assignmenttrueEnable the public API documentation and OpenAPI surface.
EXPOSE_FRONTENDActive assignmenttrueEnable the public static web console; data operations still require the configured API token.
OCR_CORS_ORIGINSActive assignment(empty)Comma-separated origins passed verbatim to the CORS allowlist; empty sends no CORS headers. Add the literal null only for a standalone file:// page calling the loopback API, and prefer explicit origins over *. Preflights are answered before authentication — this is a browser policy, not an access token.
MCP_ALLOWED_HOSTSActive assignment(empty)MCP Host allowlist. Empty uses loopback/local aliases; explicit values replace those defaults.
MCP_ALLOWED_ORIGINSActive assignment(empty)MCP browser Origin allowlist. Empty permits no browser clients.
OCR_MAX_QUEUE_SIZEActive assignment16Admission capacity for document preparation and parsing requests.
OCR_ELEMENT_MAX_SLOTSActive assignment32Maximum admitted focused-image OCR slots.
OCR_ELEMENT_MEMORY_BYTESActive assignment536870912Estimated shared memory budget for decoding, copies and encoded images in focused OCR requests, in bytes.
OCR_REQUEST_TIMEOUTActive assignment600Total API request deadline, in seconds; upload time consumes this budget.
OCR_PAGE_TIMEOUTActive assignment120Per-page processing timeout, in seconds.
MAX_FILE_BYTESActive assignment31457280Maximum decoded input file size, in bytes. Align the MCP file limit when using MCP.
OCR_MAX_EMBEDDED_IMAGE_BYTESActive assignment20971520Maximum embedded-image size, in bytes.
OCR_MAX_PAGESActive assignment50Upper bound for a request's max_pages (422 above it). /parse truncates longer documents with a pages_truncated warning; /parse/chunks refuses them unless the request sets max_pages explicitly.
OCR_RATE_LIMIT_REQUESTS_PER_MINUTEActive assignment3600API requests per minute per client. Zero disables rate limiting. GET /stats, /metrics and /parse/progress/{id} are exempt so console polling cannot starve callers.
OCR_RATE_LIMIT_BURST_SIZEActive assignment120Per-client burst allowance for the API token bucket.
OCR_RATE_LIMIT_MAX_CLIENTSActive assignment10000Maximum tracked client entries in the API limiter.
OCR_RATE_LIMIT_IDLE_SECONDSActive assignment600Idle lifetime of a tracked limiter client, in seconds.
OCR_PARSE_DPIActive assignment250PDF rasterization resolution, from 50 to 400 DPI.
OCR_PDF_MAX_PAGE_PIXELSActive assignment25000000Maximum rasterized pixels for one PDF page; excess is rejected with 413.
OCR_OFFICE_ENABLEDActive assignmenttrueEnable Office/OpenDocument conversion through headless LibreOffice.
OCR_SOFFICE_PATHActive assignment(empty)Optional executable path inside the container. Empty searches the container PATH for soffice/libreoffice.
OCR_OFFICE_TIMEOUT_SECONDSActive assignment120Office conversion timeout, in seconds, including admission to the serialized converter.
OCR_AUTOTUNEActive assignmentquickHardware tuning mode: off, quick or full.
OCR_TUNING_OBJECTIVEActive assignmentbalancedCalibration objective: balanced, latency or throughput.
OCR_AUTOTUNE_FORCEActive assignmentfalseForce a new hardware calibration instead of reusing a valid profile.
OCR_AUTOTUNE_MAX_SECONDSActive assignment(empty)Calibration admission budget, checked between passes. Empty uses 600 seconds for quick or 1200 for full. Native work already running may overrun.
OCR_HEALTH_START_PERIODActive assignment1500sCompose healthcheck start_period for ocr-api (layout model download and startup calibration), expressed as a Compose duration; vllm-paddleocr keeps a fixed 600s.
OCR_VL_LANESActive assignment(empty)Manual recognition-lane override. Empty permits a calibrated profile or fallback.
OCR_PAGE_PARALLELISMActive assignment(empty)Only 1 is supported. The Paddle predictor processes pages serially; other values are rejected.
OCR_LAYOUT_THREADSActive assignment(empty)Manual Paddle CPU-thread override for layout pre- and post-processing; the PP-DocLayoutV3 network itself runs on the GPU. Empty permits a calibrated profile or fallback.
OCR_API_CPUSActive assignment4.0CPU limit of the ocr-api container for rasterization, Office conversion and chunking; layout analysis runs on the GPU. Changing it triggers recalibration. It must not exceed the host's CPU count, or Docker refuses to start ocr-api.
OCR_LAYOUT_GPU_MEMORY_MBActive assignment3584VRAM cap in MiB for PP-DocLayoutV3 layout analysis, which runs on the GPU in ocr-api next to vLLM. The pipeline peaks at about 3.1 GB on 16-page blocks at 250 DPI; 3072 runs out of memory. Raise it with OCR_PARSE_DPI or the pixel budgets. Needs an 8 GB card at least; on 8 GB cards restart vllm-paddleocr and ocr-api together, since layout keeps its VRAM and a lone vLLM restart may not fit its KV cache.
OCR_VL_MAX_INFLIGHTActive assignment16Shared API admission slots, capped by OCR_VLLM_MAX_NUM_SEQS. Each element call or native parsing worker takes one slot; a parsing worker can dispatch OCR_VL_LANES block requests. This does not cap all upstream VL requests.
OCR_TABLE_REREADActive assignment(empty)Second reading of a table or list block the reading model looped on. Such a block comes back cut to a stub or with repeated rows; /parse and /parse/chunks then read it once more at two megapixels and keep the second reading only when it passes the same checks and says more than the first. The table_suspect warning names the block and the outcome either way. false only warns; empty keeps the built-in default (true).
OCR_VLLM_IMAGEActive assignmentocr-vllm:0.32.0-securityDefault local security image built from the digest-pinned base in Dockerfile.vllm. A custom override is excluded from launcher builds and needs a separate audit.
OCR_VLLM_SERVED_MODEL_NAMEActive assignment(empty)Optional served-model alias shared by the API and model server. Empty uses PaddleOCR-VL-0.9B.
OCR_VLLM_MODEL_REVISIONActive assignment(empty)Pinned model/code revision. Empty uses the verified revision; any other value is handed to vLLM as --revision/--code-revision and to ocr-api unchanged, so recalibrate and re-run quality checks after changing it.
OCR_HF_CACHE_DIRActive assignment/app/model_cache/hfRead-only model/tokenizer cache path as seen inside the API container.
OCR_GPU_DEVICEActive assignment(empty)Docker/NVIDIA index of the one GPU reserved by both vLLM and the API. Empty selects GPU 0; -GpuDevice / --gpu-device overrides it for one run.
OCR_VLLM_GPU_MEM_UTILActive assignment(empty)Manual GPU-memory utilization override, a fraction in (0, 1]. Empty permits hardware selection; a value that cannot hold the model (about 3.5 GB) or exceeds the free VRAM budget aborts vLLM startup.
OCR_VLLM_MAX_NUM_SEQSActive assignment(empty)Manual concurrent-sequence override. Empty permits the vLLM hardware tier; the API has a fallback of 16.
OCR_VLLM_ENFORCE_EAGERActive assignment(empty)Manual eager-execution override. Empty keeps CUDA graphs enabled (no tier selects eager mode); true disables them.
OCR_VLLM_MAX_NUM_BATCHED_TOKENSActive assignment(empty)Model-server batch token budget. Empty uses 16384 tokens.
OCR_VLLM_MAX_MODEL_LENActive assignment(empty)Model context limit. Empty uses 16384 tokens.
OCR_VLLM_MM_PROCESSOR_CACHE_GBActive assignment(empty)Multimodal processor cache size, in GiB. Empty uses zero.
OCR_VLLM_USE_V2_MODEL_RUNNERActive assignment0Zero selects the Docker Desktop/WSL-compatible V1 runner. V2 requires CUDA UVA.
OCR_CHUNK_MAX_INPUT_BYTESActive assignment33554432Maximum serialized chunking input size, in bytes.
OCR_CHUNK_MAX_BLOCKSActive assignment20000Maximum input blocks considered by chunking.
OCR_CHUNK_MAX_UNITSActive assignment20000Maximum chunking units admitted per request.
OCR_CHUNK_MAX_TOKENSActive assignment32768Maximum requested per-chunk token budget.
OCR_CHUNK_MAX_DP_EDGESActive assignment320000Bound on dynamic-programming edges evaluated while choosing chunk boundaries.
OCR_CHUNK_MAX_SPLIT_EVALUATIONSActive assignment100000Bound on candidate split evaluations for one chunking request.
OCR_CHUNK_MAX_TOKEN_EVALUATIONSActive assignment1100000Bound on tokenizer evaluations for one chunking request.
OCR_CHUNK_MAX_RENDERED_BYTESActive assignment268435456Maximum intermediate rendered text size, in bytes.
OCR_CHUNK_MAX_TABLE_CELLSActive assignment100000Maximum table cells considered during chunking.
OCR_CHUNK_MAX_OUTPUT_CHUNKSActive assignment10000Maximum returned chunk count.
OCR_CHUNK_MAX_OUTPUT_BYTESActive assignment67108864Maximum serialized chunking result size, in bytes.
OCR_CHUNK_MAX_WORKERSActive assignment2Maximum CPU worker processes for chunking.
OCR_CHUNK_TIMEOUT_SECONDSActive assignment120Chunking execution deadline, in seconds.
OCR_CHUNK_QUEUE_WAIT_SECONDSActive assignment0.5Maximum wait for chunking admission, in seconds.
MCP_HTTP_TIMEOUTActive assignment660Upstream inference HTTP phase timeout, in seconds. Keep it above the API request deadline.
MCP_CHUNK_HTTP_TIMEOUTActive assignment780Total RAG upstream deadline, in seconds. Keep at least API request timeout + chunking timeout + 30.
MCP_CHUNK_MAX_ARGUMENT_BYTESActive assignment8388608Maximum UTF-8 serialized RAG arguments, in bytes, checked again after source preparation.
MCP_CHUNK_MAX_RESULT_BYTESActive assignment8388608Complete serialized RAG result limit, including summary and metadata; also the raw-byte cap for storage/Office downloads. Minimum 1024.
MCP_DIAGNOSTIC_TIMEOUTActive assignment5Total diagnostic GET budget, in seconds, including retries and backoff.
MCP_STORAGE_TIMEOUTActive assignment150Total upstream storage request deadline, in seconds.
MCP_RETRY_ATTEMPTSActive assignment3Maximum attempts (1–10) for idempotent diagnostic and storage GETs within their deadline. Inference POSTs are never retried.
MCP_RETRY_BACKOFF_SECONDSActive assignment0.5Initial retry backoff for diagnostic and storage GETs, in seconds, with jitter.
MCP_INPUT_ROOTSActive assignment(empty)Semicolon-separated directories accessible on the MCP server. Empty disables local-file access; Docker also needs explicit read-only mounts.
MCP_MAX_FILE_BYTESActive assignment31457280Maximum decoded MCP input file size, in bytes. Align with the API input cap.
OCR_STORAGE_ENABLEDActive assignmentfalseEnable writing OCR outputs to the configured S3 archive; run the storage configuration helper first.
OCR_STORAGE_BROWSER_ENABLEDActive assignmentfalseEnable the /storage/* routes, the console STORAGE tab and MCP archive browsing/deletion with the separate OCR_S3_BROWSER_* identity (startup fails without it); single-file deletion and RAG refinement also need OCR_STORAGE_ENABLED.
OCR_S3_ENDPOINTActive assignmenthttp://storage-gateway:8333Internal S3 gateway endpoint. Host clients use the published loopback S3 port instead.
OCR_S3_BUCKETActive assignmentocr-outputsBucket used for archived OCR outputs.
OCR_S3_REGIONActive assignmentus-east-1S3 signing region.
OCR_S3_ADDRESSING_STYLEActive assignmentpathS3 addressing style for the configured backend.
OCR_S3_RETENTION_DAYSActive assignment30Bucket lifecycle expiration in days, applied by storage-init; 0 disables it. verify requires an integer ≥ 0.
OCR_STORAGE_TIMEOUT_SECONDSActive assignment10Storage operation timeout, in seconds.
OCR_STORAGE_MAX_INFLIGHTActive assignment2Maximum concurrent archive-write operations.
OCR_STORAGE_MAX_BYTESActive assignment134217728Maximum archived/downloaded content budget, in bytes.
OCR_STORAGE_MAX_OBJECTSActive assignment1024Maximum objects in one archived output set.
OCR_STORAGE_SAVE_INPUTActive assignmentfalseOpt in to archiving original source documents. Consider their confidentiality and retention.
OCR_STORAGE_SAVE_PARSEDActive assignmenttrueSave the pre-chunking /parse result as parsed.json in /parse/chunks archives; /parse archives always keep their JSON and Markdown.
OCR_S3_ADMIN_ACCESS_KEYActive assignment(empty)Provisioning administrator access key. Generated locally; never passed to the API.
OCR_S3_ADMIN_SECRET_KEYActive assignment(empty)Provisioning administrator secret. Keep it in local configuration only.
OCR_S3_ACCESS_KEYActive assignment(empty)API writer access key for listing/writing archives.
OCR_S3_SECRET_KEYActive assignment(empty)API writer secret, generated by the storage helper.
OCR_S3_READER_ACCESS_KEYActive assignment(empty)External read-only archive access key.
OCR_S3_READER_SECRET_KEYActive assignment(empty)External read-only archive secret.
OCR_S3_BROWSER_ACCESS_KEYActive assignment(empty)API browser access key for listing, reading and deleting archives.
OCR_S3_BROWSER_SECRET_KEYActive assignment(empty)API browser secret, separate from writer and administrator identities.
OCR_SEAWEED_ADMIN_PASSWORDActive assignment(empty)Separate SeaweedFS console password for the administrator.
OCR_SEAWEED_READER_PASSWORDActive assignment(empty)Separate SeaweedFS console password for the reader.
MCP_UPSTREAM_URLCommented native examplehttp://127.0.0.1:8020Native MCP endpoint for the API. Compose fixes its internal service URL instead.
MCP_BIND_HOSTCommented native example127.0.0.1Native MCP advertised bind host/default Host allowlist. Does not change Compose host publication.
MCP_LISTEN_HOSTCommented native example127.0.0.1Native MCP listener address. Compose fixes the container listener to 0.0.0.0 behind loopback publication.
MCP_ALLOW_UNAUTHENTICATED_LOCALCommented native examplefalseNative-only explicit anonymous mode, allowed only with both MCP hosts on loopback. Compose fixes this to false.
OCR_VLLM_URLCommented native examplehttp://127.0.0.1:8081/v1Native API endpoint for the model server. Export it in the API process environment; Compose fixes the internal URL.
OCR_VLLM_SERVED_MODELCommented native examplePaddleOCR-VL-0.9BNative API model alias. Compose supplies the shared alias through its service environment.
Validate the configuration before rebuilding and recreating containers.
No. This is a static reference to the versioned template. It never reads your .env, accepts a credential or saves changes.
Run from the repository root
pwsh .\stack.ps1 verify
pwsh .\stack.ps1 up -Wait
bash stack.sh verify
bash stack.sh up --wait
Restart alone retains container configuration. Check shell overrides if the applied value differs from your file.
Run from the repository root
python scripts/configure_storage.py
python3 scripts/configure_storage.py
The helper generates missing credentials locally, preserves existing values and enables the storage profile. It is an explicit operator action; this guide does not run it.
Section 14 documents native-process variables (such as MCP_UPSTREAM_URL and OCR_VLLM_URL). Stock compose.yml pins internal container URLs and bind addresses directly so host port edits do not break container-to-container routing.
These guides teach the workflow. The owning documents define its exact behavior.
Every command, flag, exit behavior and recovery boundary.
Read the CLI reference ↗Template defaults, token relationships and deployment details.
Read the environment reference ↗