Deployer for limedoc based static sites
  • TypeScript 93.6%
  • Shell 4%
  • HTML 2.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Oliver Maklott f33097a266
All checks were successful
Test / test (push) Successful in 14s
Release / release (push) Successful in 26s
Merge pull request 'Release 0.3.0: reload token and keys on refusal; onboarding docs' (#6) from reload-credentials into main
2026-12-02 01:54:45 +01:00
.forgejo/workflows Release workflow: compiled Linux amd64 binary per version tag 2026-11-29 20:56:44 +01:00
.githooks Sites deployer 0.1.0: pull, verify, materialize, render, reload. 2026-11-20 11:21:58 +01:00
ci One wildcard certificate per target domain (DNS-01) instead of one per site. 2026-11-20 19:52:47 +01:00
deploy Reload the token file and keys when Limedoc refuses the token or signs with an unknown key, so rotations need no restart; README and example config point at Admin → Pack pages → sites · targets → Connect deployer. Release 0.3.0. 2026-12-02 01:37:28 +01:00
src Reload the token file and keys when Limedoc refuses the token or signs with an unknown key, so rotations need no restart; README and example config point at Admin → Pack pages → sites · targets → Connect deployer. Release 0.3.0. 2026-12-02 01:37:28 +01:00
tests Reload the token file and keys when Limedoc refuses the token or signs with an unknown key, so rotations need no restart; README and example config point at Admin → Pack pages → sites · targets → Connect deployer. Release 0.3.0. 2026-12-02 01:37:28 +01:00
.gitignore Repository: README, FSL-1.1-ALv2 license, .gitignore. 2026-11-20 11:21:56 +01:00
deno.json Reload the token file and keys when Limedoc refuses the token or signs with an unknown key, so rotations need no restart; README and example config point at Admin → Pack pages → sites · targets → Connect deployer. Release 0.3.0. 2026-12-02 01:37:28 +01:00
deno.lock Sites deployer 0.1.0: pull, verify, materialize, render, reload. 2026-11-20 11:21:58 +01:00
LICENSE.md Repository: README, FSL-1.1-ALv2 license, .gitignore. 2026-11-20 11:21:56 +01:00
README.md Reload the token file and keys when Limedoc refuses the token or signs with an unknown key, so rotations need no restart; README and example config point at Admin → Pack pages → sites · targets → Connect deployer. Release 0.3.0. 2026-12-02 01:37:28 +01:00

limedoc-sites-deployer

Keeps one deployment target's websites on a hosting server equal to the signed desired state the Limedoc Sites pack publishes. It pulls (no incoming ports), verifies, materializes immutable releases, writes Caddy host files and reloads Caddy. Limedoc never writes to a hosting server.

Source-available under FSL-1.1-ALv2 (LICENSE.md).

How it works

  1. Long-poll GET /api/plugins/sites/targets/<id>/desired?since=<serial>&wait=30 with the target's bearer token. Network errors: back off up to 60 s; what is served stays as it is.
  2. Verify the Ed25519 signature (key pinned by keyId in the config's keys) over the canonical payload, the target id and a strictly larger serial. Then validate every host, user name, bcrypt hash, capability, audience and manifest path. Anything wrong: the state is dropped, nothing changes.
  3. Fetch missing manifests and objects, check their SHA-256 (and size), build releases/<manifest>/ from hardlinks into objects/ in a temp directory and rename it. The library catalog (payload.libs) the same way under libs/<sha>/, linked as lib.
  4. Render one host file per site into <renderDir>/<serial>/, and access.json (gate rules of oidc sites). It stays format 1 ({host: audience}) until a site is private or names people (owner, visitors, guardians as subject hashes, ADR 0007); then it is format 2 ({host: {audience, people?}}), which needs limedoc-sites-gate 0.2.0 or newer (0.2.1 for visitors of sites without school claims, as in general targets). Update the gate first.
  5. Swap the live/<host> links, then the sites.d/<target> link, then run the reload command. If Caddy refuses the config, every link and access.json go back and the error is reported.
  6. After a successful reload: remove links of hosts no longer listed (a takedown is one reload), write state.json, collect garbage (3 releases per host, unreferenced objects, the last 3 rendered sets).

A fresh server rebuilds itself completely from the current state.

Layout (per target)

/srv/sites/schule/
  objects/<sha256>            file contents, 0644
  manifests/<sha256>.json     manifests as fetched (hash-checked)
  releases/<manifest>/…       hardlinks into objects/
  live/<host> -> ../releases/<manifest>
  libs/<sha>/<name>/<version>/…   library catalog; lib -> libs/<sha>
  state.json                  applied serial, keyId, kept releases per host
  access.json                 gate rules (oidc sites)
/etc/caddy/sites-rendered/schule/<serial>/<host>.caddy
/etc/caddy/sites.d/schule -> /etc/caddy/sites-rendered/schule/<serial>

Differences from the specification, where the code wins: rendered sets live outside sites.d and the main Caddyfile imports sites.d/<target>/*.caddy once per target (<target> is the target's id, e.g. schule) — Caddy accepts only one wildcard per import, so sites.d/*/*.caddy does not load. Certificates are one wildcard per target domain (DNS-01) instead of one per site (operator decision 2026-11-20).

Install

Binary (Linux amd64)

Every release (from 0.2.1) carries a compiled binary for Linux amd64, together with LICENSE.md, this README and deploy/ (Caddyfile, systemd unit, static pages, examples) of that version:

VERSION=0.2.1
NAME=sites-deployer-${VERSION}-linux-amd64
BASE=https://git.belowtoxic.cloud/limedoc/limedoc-sites-deployer/releases/download/v${VERSION}
curl -fsSLO "$BASE/$NAME.tar.gz" -O "$BASE/$NAME.sha256"
sha256sum -c "$NAME.sha256"
tar -xzf "$NAME.tar.gz"
sudo install -m 0755 "$NAME/sites-deployer" /usr/local/bin/sites-deployer

Releases: https://git.belowtoxic.cloud/limedoc/limedoc-sites-deployer/releases. An update is the same with the new version, then sudo systemctl restart 'sites-deployer@*' (when a release needs a newer limedoc-sites-gate, update the gate first).

From source (other architectures)

Needs Deno 2.x. In a checkout of the release tag (git checkout v<version>):

  • deno task compile → dist/sites-deployer for the machine it runs on; copy it to /usr/local/bin/.
  • To build for another machine, run the same deno compile command as the compile task in deno.json with --target, e.g. --target aarch64-unknown-linux-gnu.

Server setup

  • Caddy ≥ 2.10 with deploy/Caddyfile as the main config (admin API on unix//run/caddy/admin.sock, group caddy-admin, no admin port); static pages from deploy/static/ in /srv/sites/static.
  • Certificates: one wildcard certificate per target domain (*.aivopod-sites.eu) through the DNS-01 challenge, so publishing a site never waits for a certificate and no site name shows up in CT logs. Build Caddy with the DNS module of your provider (xcaddy build --with github.com/caddy-dns/<provider>), copy deploy/tls.caddy.example to /etc/caddy/tls.caddy and put the API credentials in caddy.service's environment. The apex (info page) keeps a certificate of its own. DNS: the apex and *.aivopod-sites.eu point at the server (auth. is covered by the wildcard).
  • In Limedoc (0.92.0 or newer, Sites pack 0.6.0 or newer, loaded: Admin → Plugins shows Sites with a Settings button): Admin → Pack pages → sites · targets (/<locale>/admin/plugins/sites/targets) → New target. Its id is this deployer's target, its domain the domain. Saving opens Connect deployer, which issues the deployer token (shown once) and the signing key, and shows this target's ready config (target, domain, baseUrl, tokenFile, keys: { "<key id>": "<public key>" } and the paths below). On a connected target "Deployer setup" shows it again.
  • Per target: a user sites-<target> in caddy-admin, owning /srv/sites/<target> and /etc/caddy/sites-rendered/<target>, with write access to /etc/caddy/sites.d; config /etc/sites-deployer/<target>.json (see deploy/config.example.json, or copy the one Connect deployer shows), the token file (one line, mode 0600, owned by sites-<target>) and systemctl enable --now sites-deployer@<target> (unit).
  • Rotation: "New deployer token" / "New signing key" on the target. Write the new token into tokenFile, or add the new key to keys (keep the old one until the new key signs). A running deployer reads both again when Limedoc refuses its token (401) or signs with a key it does not know (credentials-reloaded in the log); no restart needed.
  • Add import /etc/caddy/sites.d/<target>/*.caddy to the main Caddyfile.

sites-deployer once --config … applies the current state and exits (exit 1 on an error). The status socket (statusSocket) answers GET / with serial, number of sites, last apply, last reload and last error: curl --unix-socket /run/sites-deployer/schule.sock http://x/. Logs go to journald as JSON lines, without IP addresses.

Development

deno task check   # fmt, lint, types
deno task test    # verification, validation, rendering, apply runs
deno task golden  # rewrite tests/golden/*.caddy after a template change
sh ci/caddy_validate.sh /path/to/caddy   # needs Caddy >= 2.10

The header profile (src/header_profile.ts) and canonical JSON (src/canonical.ts) carry the same golden vectors as the Sites pack; a change there is a change on both sides. CI validates deploy/Caddyfile with every golden host file using a pinned, checksum-verified Caddy.

Release

Bump version in deno.json, merge to main, then tag that commit on main v<version> and push the tag. release.yml runs the checks and tests again, compiles the Linux amd64 binary and publishes the tarball and its .sha256 as the tag's release. To release an older tag or retry a failed run, start the Release workflow by hand with tag (e.g. v0.2.1); a release whose .sha256 is already attached is left as it is.