The practical startup & recovery guide

Start, inspect,
recover.

One Python planner gives PowerShell and Bash the same startup order; recovery commands run without it. Preview a command, then run it yourself.

Startup order01 → 04
  1. 01
    Verify and buildCheck token/storage contracts and Compose security before changing services.
  2. 02
    Wait for dependenciesAwait GPU model server (vllm-paddleocr) and optional S3 storage initialization.
  3. 03
    Calibrate APIAwait the smart-document-manager container's hardware profile and health.
  4. 04
    Start MCPStart smart-document-mcp; optional listener wait, discovery is separate.
Failure stops subsequent stages. Existing data is retained for diagnosis.
Smart Document Manager / Unified PowerShell & Bash launcher workflow
01 / Before you type

A folder. A few tools.
A GPU for the model.

Prepare these once. After that, the same launcher handles your ordinary starts and stops.

The repository root

Start in the right place.

Open a terminal in the repository root. You should see stack.ps1, stack.sh, compose.yml and .env.example. The launchers never create or rewrite .env for you.

Windows examples use PowerShell 7 (pwsh). In Windows PowerShell 5.1, use .\stack.ps1 in place of pwsh .\stack.ps1.

The tools

Docker + Python.

Docker runs the services in containers; start Docker Desktop or your Docker Engine first. The launchers need Compose 2.24.4 or newer and Python 3.11 or newer on your command path.

Check the exact prerequisites ↗
The GPU

NVIDIA, visible to Docker.

The model server runs on compatible NVIDIA hardware with a GPU-capable Docker runtime. There is no CPU-only stack mode — the model server and API entrypoints tier and budget from the hardware they find. With several GPUs the stack uses GPU 0; pick another with -GpuDevice 1 / --gpu-device 1.

GPU tiering reference ↗

Allow disk space and time for container images and the model download. The first preparation needs network access. The getting-started guide walks through the same first run with agent setup.

02 / Follow along

Your first start,
one clear step at a time.

Each step has a Windows and a Linux command that apply the same choices. Preview the plan before you commit to the wait.

  1. Create your settings file.

    Copy .env.example to .env only if it does not exist — the command keeps an existing file. Then set your three distinct secrets as in the getting-started guide.

    Create .env without replacing an existing file

    Windows · PowerShell 7
    if (-not (Test-Path -LiteralPath .env)) {
        Copy-Item -LiteralPath .env.example -Destination .env
    }
    Linux / macOS · Bash
    if [ ! -e .env ]; then cp .env.example .env; fi

    What to check
    Your settings are saved in the repository root, alongside the launchers.

  2. Check the configuration.

    verify checks the token/storage relationships and both Compose profile shapes for security problems. It touches no Docker state and does not prove the app is running.

    Run from the repository root

    Windows · PowerShell 7
    pwsh .\stack.ps1 verify
    Linux / macOS · Bash
    bash stack.sh verify

    What to check
    The checks finish successfully. Fix anything reported now — it is cheaper than diagnosing a half-started stack.

  3. Preview the plan.

    -DryRun / --dry-run resolves the service selection and prints the planned steps without running verifiers or mutating anything. Use it to confirm the start order matches your expectation.

    Run from the repository root

    Windows · PowerShell 7
    pwsh .\stack.ps1 up -DryRun
    Linux / macOS · Bash
    bash stack.sh up --dry-run

    What to check
    The plan names verify, build, the vLLM wait, optional storage init, API calibration and MCP — in that order.

  4. Build and start.

    up re-runs the preflight, builds images and starts services in readiness order. The wait flag holds for vLLM, API calibration and the MCP listener too. The first start can take tens of minutes — downloads and calibration are real work.

    Run from the repository root

    Windows · PowerShell 7
    pwsh .\stack.ps1 up -Wait
    Linux / macOS · Bash
    bash stack.sh up --wait

    What to check
    The command finishes and the serving containers are healthy. A timeout leaves containers in place for diagnosis — inspect status and logs before retrying.

  5. Find the app. Check its health.

    urls prints the configured loopback addresses and whether each needs a token — it is not a live probe. status shows container state, including optional storage. Open the console address and look for healthy with vLLM reachable.

    Run from the repository root

    Windows · PowerShell 7
    pwsh .\stack.ps1 urls
    pwsh .\stack.ps1 status
    Linux / macOS · Bash
    bash stack.sh urls
    bash stack.sh status

    What to check
    The default console address is http://127.0.0.1:8020. Then follow the first-extraction walkthrough.

03 / Interactive command preview

Choose the next
operation.

Both shell variants stay visible. The builder never accepts credentials.

PowerShell 7 + Bash · Side-by-side preview

Command preview only. Nothing is executed, saved or read from your local configuration.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 up -Wait

Linux / macOS · Bash
bash stack.sh up --wait

Model and API readiness are always awaited. The extra wait checks the MCP listener, not authenticated discovery.

04 / Daily operations

Use the command
for the change.

Expand an operation for its exact purpose. The full flag matrix belongs to the launcher reference.

Verify before changing the stack

Checks token/storage relationships and base/storage Compose hardening. No Docker daemon or live model is required.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 verify

Linux / macOS · Bash
bash stack.sh verify

Start or apply configuration changes

Builds before modifying services, then waits in dependency order. The default per-stage readiness budget is 3600 seconds; change it with -WaitTimeout <seconds> / --wait-timeout <seconds>, which also implies the wait. -NoBuild / --no-build skips the build step.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 up -Wait

Linux / macOS · Bash
bash stack.sh up --wait

Build or pull images without starting anything

build builds vLLM's security layer, ocr-api and, when enabled, ocr-mcp. pull refreshes the pinned vLLM base and security layer (or pulls a custom OCR_VLLM_IMAGE from its registry), then the storage images when that profile is enabled. Neither starts a container.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 build
pwsh .\stack.ps1 pull

Linux / macOS · Bash
bash stack.sh build
bash stack.sh pull

Restart existing containers without reloading .env

Restarts running services with their existing container configuration and images. Use up when applying edited .env values.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 restart

Linux / macOS · Bash
bash stack.sh restart

Inspect the resolved configuration

Redacts credentials by default; -ShowSecrets / --show-secrets prints them in cleartext with a warning. Do not paste raw docker compose config output into an issue.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 config

Linux / macOS · Bash
bash stack.sh config

Find configured entry points

Shows configured loopback URLs and authentication state, never tokens. It makes no live health probe.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 urls

Linux / macOS · Bash
bash stack.sh urls

Inspect container state

Includes optional storage containers. Recovery commands work without Python and local .env.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 status

Linux / macOS · Bash
bash stack.sh status

Inspect a bounded log excerpt

Logs follow by default; -Tail <lines> / --tail <lines> or -Since <time> / --since <time> suppress implicit following. Add -Follow / --follow if needed.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 logs -Service ocr-api,vllm-paddleocr -Tail 100

Linux / macOS · Bash
bash stack.sh logs --service ocr-api,vllm-paddleocr --tail 100

Stop while retaining data

Named volumes survive. -Volumes / --volumes deletes model caches, tuning state and stored archives and requires explicit confirmation with -Yes / --yes; it is intentionally absent from the preview builder. -RemoveOrphans / --remove-orphans also removes containers the Compose file no longer defines.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 down

Linux / macOS · Bash
bash stack.sh down

Inspect available commands and versions

Help, version, status, logs and down bypass the Python planner and use the template for recovery when no env file is explicitly selected.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 help
pwsh .\stack.ps1 version

Linux / macOS · Bash
bash stack.sh help
bash stack.sh version

05 / GPU overrides, storage and isolation

Same launcher.
Different intent.

Flags override your configured choices for one run; they do not rewrite .env. Reach for them deliberately.

Optional / S3 archive

Enable storage explicitly.

The storage profile adds SeaweedFS, a gateway and a one-shot initializer. Generate its local credentials first; startup then provisions the bucket and identities before the API.

Storage setup below ↓
Service selection

Drop MCP or the console.

-NoMcp / --no-mcp omits the MCP server for that run on up, config, verify, build, pull, restart and urls; on up it also stops and removes a running MCP container. -Mcp / --mcp forces it on. -NoFrontend / --no-frontend and -Frontend / --frontend override EXPOSE_FRONTEND on up and config. -GpuDevice 1 / --gpu-device 1 runs vLLM and the API on GPU 1 for that up or config, overriding OCR_GPU_DEVICE.

Archive-only / zero VRAM

Read archives without the GPU.

-ArchiveOnly / --archive-only (or OCR_ARCHIVE_ONLY=true in .env) starts the stack without vllm-paddleocr and without reserving a GPU: a leftover model container is stopped, the API skips calibration, /parse, /ocr and /parse/chunks answer 503 ocr_disabled_archive_only, and /health reports mode=archive_only with vllm=disabled. The console, /storage/* and the MCP storage tools read everything archived earlier. It needs storage and its browser enabled; a plain up later restores the full GPU stack, unless .env fixes OCR_ARCHIVE_ONLY=true, which you edit or override from the shell (OCR_ARCHIVE_ONLY=false) first.

Archive-only commands ↓
Naming, not isolation

Project names do not isolate.

-EnvFile / --env-file selects another existing env file. -ProjectName / --project-name changes Compose bookkeeping only — container, network and volume names are fixed, so one stack per Docker daemon.

Why it cannot isolate ↓
Enable the local storage archive

The helper writes missing OCR_S3_* / OCR_SEAWEED_* credentials into .env locally, preserves existing values, enables OCR_STORAGE_ENABLED and OCR_STORAGE_BROWSER_ENABLED (the /storage routes, the console STORAGE tab and the MCP storage tools), seeds bucket, retention and save defaults when absent, and adds the storage profile to COMPOSE_PROFILES. It never prints secrets. The profile is optional — the API runs without it.

Run from the repository root

Windows · PowerShell 7
python scripts/configure_storage.py
pwsh .\stack.ps1 up -Wait
Linux / macOS · Bash
python3 scripts/configure_storage.py
bash stack.sh up --wait

Consult archives without a GPU (archive-only)

The overlay compose.archive-only.yml is merged after compose.yml: vllm-paddleocr leaves the resolved model, ocr-api loses its vLLM dependency and GPU reservation and receives OCR_ARCHIVE_ONLY=true. build and pull skip the model server too, restart leaves it alone and never changes mode (switch with up), config renders the merged shape, urls names the mode and verify always checks both shapes. It requires OCR_STORAGE_ENABLED, OCR_STORAGE_BROWSER_ENABLED and archives from earlier OCR runs; -GpuDevice / --gpu-device is refused together with it and OCR_GPU_DEVICE in .env is ignored for that run. Switching either way deletes no archive, volume or model cache.

Run from the repository root

Windows · PowerShell 7
pwsh .\stack.ps1 up -ArchiveOnly -Wait
Linux / macOS · Bash
bash stack.sh up --archive-only --wait

GPU and image overrides

Leave the GPU override settings empty: the model server and API entrypoints fingerprint your hardware and choose the tier and budgets automatically. Fill them only with a measured reason — a wrong budget is a new problem, not a tuning fix.

Choosing the card is not a budget override. OCR_GPU_DEVICE in .env, or -GpuDevice / --gpu-device for one run, sets the Docker/NVIDIA index (usually the nvidia-smi order) of the single GPU that vllm-paddleocr and the smart-document-manager container share. Apply a change with up, not restart; a different GPU model triggers a new calibration.

A custom OCR_VLLM_IMAGE is preserved: launchers skip its build and pull fetches it from its registry. Use the launchers rather than docker compose up --build, which would overwrite the local custom tag.

When would I use --skip-verify?

-SkipVerify / --skip-verify bypasses the security preflight on up. Treat it as a deliberate exception: the preflight catches token/storage misconfiguration and Compose hardening problems before containers change. Skip it and the first complaint may arrive mid-startup instead.

06 / Command boundaries

Resolve the command
boundary.

Configuration verification, readiness and authenticated tool discovery prove different things.

Why did restart keep the old setting?

Restart reuses the existing container configuration. Apply edits with up. Shell values override the selected env file, and explicit CLI selection takes precedence.

Can a project name create an independent stack?

No. Container, network and volume names are fixed. Project names do not isolate data or support concurrent copies on one Docker daemon.

Can I use a CPU/GPU positional argument?

No. This stack always requires NVIDIA hardware. Native startup has separate environment semantics; see the configuration reference.

Do recovery commands need Python or a valid .env?

No. down, status, logs, help and version bypass Python and fall back to .env.example with the storage profile enabled so you can always inspect or stop containers — unless -EnvFile / --env-file names a file, which must then exist.

What do the exit codes mean?

0 is success. 1 is a missing prerequisite: Docker, its daemon, the Compose version or the selected env file. 2 is a usage, configuration or preflight error. Any other code is Docker's own, passed through unchanged. PowerShell parameter-binding failures can exit 1 before the script body runs; Bash reports those as 2.

The first start is taking a very long time.

Cold starts can take tens of minutes: image builds, the model download and calibration are real work, and each readiness stage has a finite wait budget. A timeout leaves containers available for diagnosis — it does not erase volumes or undo completed provisioning.

Inspect status and logs for the stage still waiting before retrying. Later starts reuse the built images and cached model.

07 / Keep going

Keep the contract
close.

These guides teach the workflow. The owning documents define its exact behavior.

Technical references for the person running the app