Skip to content

Self-hosted and Compose

You can run the uShelf image on any platform, such as Docker Compose, Kubernetes, or a PaaS, and still use the CLI and MCP bridge against it.

The image is ghcr.io/karamouche/ushelf:<version>. Give it:

  • A persistent volume mounted at /data.
  • USHELF_HOST=0.0.0.0 so it listens inside the container, and optionally USHELF_PORT (default 43110).
  • USHELF_API_TOKEN, a random string of at least 32 characters, for example from openssl rand -base64 32.
  • USHELF_APP_PASSWORD, at least 12 characters. Without it, the server refuses to start unless you also set USHELF_PUBLISHED_HOST=127.0.0.1 to declare that the port is published only on loopback, and it then answers only the host names localhost, 127.0.0.1, and [::1] (other requests get 421 unless they carry the API token), so a proxy cannot use the reader.
  • HTTPS in front of it, preserving the original Host header.

The container runs as an unprivileged user. If it starts as root, for example on a platform with root-owned volumes, it takes ownership of /data and drops privileges before starting the server. See Configuration for every variable.

Terminal window
ushelf context add homelab --url https://ushelf.example.com

The CLI prompts for the token without echo (or reads USHELF_API_TOKEN), verifies it against the server, and makes the context current. Agent setup, Kindle, status, and doctor then work as usual. Lifecycle commands such as start, stop, and logs are left to the platform that runs it.

The repository’s compose.yaml builds the image and stores the library on the host under ~/.ushelf.

Terminal window
cp .env.example .env
printf 'USHELF_UID=%s\nUSHELF_GID=%s\n' "$(id -u)" "$(id -g)" >> .env
printf 'USHELF_API_TOKEN=%s\n' "$(openssl rand -base64 32)" >> .env
mkdir -p "$HOME/.ushelf/library/items" "$HOME/.ushelf/library/history" \
"$HOME/.ushelf/recipes" "$HOME/.ushelf/state" "$HOME/.ushelf/secrets"
chmod 700 "$HOME/.ushelf/secrets"
test -f "$HOME/.ushelf/recipes/default.md" || \
cp recipes/default.md "$HOME/.ushelf/recipes/default.md"
docker compose up -d --build
ushelf context add compose --url http://127.0.0.1:43110

Compose publishes the port on 127.0.0.1 unless .env sets USHELF_HOST. If you publish it on 0.0.0.0 or a LAN address, also set USHELF_APP_PASSWORD in .env; without it, the server refuses to start.

To use another location, set an absolute USHELF_ROOT in .env and create the same directories there. USHELF_UID and USHELF_GID let the container access your files.

Common operations:

Terminal window
docker compose logs -f ushelf
docker compose restart ushelf
docker compose down
git pull
docker compose up -d --build

To rebuild the index against the same bind mounts:

Terminal window
docker compose stop ushelf
docker compose run --rm --no-deps maintenance rebuild-index
docker compose up -d

To serve uShelf under a path such as /reader/, set USHELF_WEB_BASE_PATH=/reader/ and include the path in the context URL. uShelf normalizes the trailing slash, and your reverse proxy must preserve the prefix.