Skip to content

Deploy with Docker Compose

The repository ships a reference stack in deploy/docker/compose.yml: sklad, Caddy for TLS certificates from Let’s Encrypt, and Logto with Postgres as the OAuth 2.1 identity provider that Claude.ai needs. A single-user deployment fits on a small VPS.

  • An x86_64 Linux host with Docker Compose. The compose file runs the image tagged sklad:nix; you load it yourself, from the published image or a Nix build.
  • Two DNS names pointing at the host, here kb.example.com for sklad and auth.example.com for Logto. Create them before the first start: Caddy requests certificates as soon as it starts.
  • A git remote for the knowledge base that the server may push to.

Clone sklad, then the knowledge base inside the sklad checkout. The compose file mounts know-mount/ (the knowledge base) and state-mount/ (token database, deploy key) from the root of the sklad checkout. The image runs as UID 65532, which must own both:

Terminal window
git clone https://github.com/Zebradil/sklad.git /srv/sklad
cd /srv/sklad
git clone git@github.com:<you>/<kb>.git know-mount
mkdir -p state-mount
sudo chown -R 65532:65532 know-mount state-mount

sklad commits every write and pushes it (git.auto_push, on by default). The compose file points git at /data/state/git-key and checks the remote’s host key strictly against /data/state/known_hosts:

Terminal window
ssh-keygen -t ed25519 -f state-mount/git-key -N ""
ssh-keyscan -t ed25519,rsa -H github.com >> state-mount/known_hosts
sudo chown 65532:65532 state-mount/git-key* state-mount/known_hosts
cat state-mount/git-key.pub

Add the public key to the knowledge base repository as a deploy key with write access. Check the scanned fingerprints against your git host’s published ones before trusting them.

Create deploy/docker/.env:

Terminal window
KB_DOMAIN=kb.example.com
AUTH_DOMAIN=auth.example.com
ADMIN_EMAIL=admin@example.com
LOGTO_DB_PASSWORD=<a long random password>

Compose derives sklad’s settings from these: the OAuth issuer https://auth.example.com/oidc and audience https://kb.example.com/mcp. Optional variables AUTO_PUSH, GIT_REMOTE, and GIT_BRANCH override the push defaults (true, origin, main). For a first trial, point Caddy at Let’s Encrypt’s staging directory so failed attempts do not use up the production rate limit: add ACME_CA=https://acme-staging-v02.api.letsencrypt.org/directory to the caddy service’s environment. Setting it in .env alone does nothing, because Compose does not pass it to that container.

Other sklad settings go into the environment list of the sklad service as SKLAD_* variables. Nested keys use a double underscore, such as SKLAD_GIT__AUTO_PUSH; a single underscore is silently ignored. The configuration reference lists them all.

Each release is published as ghcr.io/zebradil/sklad:<version> for linux/amd64. Pull a release, such as 0.3.0 (see the releases), and tag it as sklad:nix, the name the compose file uses. The remaining commands run from deploy/docker/:

Terminal window
docker pull ghcr.io/zebradil/sklad:<version>
docker tag ghcr.io/zebradil/sklad:<version> sklad:nix
cd deploy/docker

To build the image from the checkout instead, run nix build .#image && ./result | docker load from its root.

Load the image before the next step: docker compose run uses whatever sklad:nix is loaded, and an older image writes older .gitignore patterns that the new server rejects.

The server refuses to start on a directory that is not a ready knowledge base: a git repository whose .gitignore covers sklad’s sidecar files, with a valid .kb/framework.toml. sklad init creates whatever is missing and leaves content alone; it is safe to run again:

Terminal window
docker compose run --rm --entrypoint sklad sklad init --path /data/know

The definition itself is yours to write; see the framework definition.

Terminal window
docker compose up -d sklad logto-db logto caddy
docker compose logs -f caddy

Watch Caddy obtain both certificates. Then check sklad from the outside:

Terminal window
curl -s https://kb.example.com/.well-known/oauth-protected-resource/mcp

Caddy passes only /mcp and the OAuth metadata to sklad. /healthz, /readyz, and the metrics listener stay inside the compose network, and so does the web view: to publish it, add routes to deploy/caddy/Caddyfile behind your own access control, see Browse the web view and share pages.

Mint a token for clients configured by hand, such as Claude Code:

Terminal window
docker compose run --rm --entrypoint sklad sklad token create \
--name laptop --scopes kb:read,kb:write

For Claude.ai, configure Logto: create an API resource with the identifier https://kb.example.com/mcp and the scopes kb:read, kb:write, and kb:admin, and enable Dynamic Client Registration. Then add the connector, see Connect MCP clients.

Load the new image, run sklad init again, and recreate the service. From the root of the sklad checkout:

Terminal window
git pull
docker pull ghcr.io/zebradil/sklad:<version>
docker tag ghcr.io/zebradil/sklad:<version> sklad:nix
cd deploy/docker
docker compose run --rm --entrypoint sklad sklad init --path /data/know
docker compose up -d sklad

Running containers do not update themselves; the image’s system packages only get security fixes with a new image.

Releases before 0.2.0 ran as kb-mcp with KBMCP_* variables, kb-mcp.toml, kbmcp_* metrics, and .kbmcp.lock.* write locks. The old and new servers lock different files, so never run both against one checkout:

  1. Stop and remove the old container first: docker stop kb-mcp && docker rm kb-mcp. Compose does not remove it once the service is renamed.
  2. Rename KBMCP_ to SKLAD_ in your environment files, and kb-mcp.toml to sklad.toml.
  3. Load the image, initialize, and start as above, then docker compose restart caddy to pick up the sklad:8080 upstream.
  4. Rename kbmcp_ to sklad_ in alert rules and dashboards.