- TypeScript 93.6%
- Shell 4%
- HTML 2.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| .githooks | ||
| ci | ||
| deploy | ||
| src | ||
| tests | ||
| .gitignore | ||
| deno.json | ||
| deno.lock | ||
| LICENSE.md | ||
| README.md | ||
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
- Long-poll
GET /api/plugins/sites/targets/<id>/desired?since=<serial>&wait=30with the target's bearer token. Network errors: back off up to 60 s; what is served stays as it is. - Verify the Ed25519 signature (key pinned by
keyIdin the config'skeys) over the canonical payload, the target id and a strictly largerserial. Then validate every host, user name, bcrypt hash, capability, audience and manifest path. Anything wrong: the state is dropped, nothing changes. - Fetch missing manifests and objects, check their SHA-256 (and size), build
releases/<manifest>/from hardlinks intoobjects/in a temp directory and rename it. The library catalog (payload.libs) the same way underlibs/<sha>/, linked aslib. - Render one host file per site into
<renderDir>/<serial>/, andaccess.json(gate rules ofoidcsites). It stays format 1 ({host: audience}) until a site isprivateor 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. - Swap the
live/<host>links, then thesites.d/<target>link, then run the reload command. If Caddy refuses the config, every link andaccess.jsongo back and the error is reported. - 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-deployerfor the machine it runs on; copy it to/usr/local/bin/.- To build for another machine, run the same
deno compilecommand as thecompiletask indeno.jsonwith--target, e.g.--target aarch64-unknown-linux-gnu.
Server setup
- Caddy ≥ 2.10 with
deploy/Caddyfileas the main config (admin API onunix//run/caddy/admin.sock, groupcaddy-admin, no admin port); static pages fromdeploy/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>), copydeploy/tls.caddy.exampleto/etc/caddy/tls.caddyand 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.eupoint 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'starget, its domain thedomain. 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>incaddy-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(seedeploy/config.example.json, or copy the one Connect deployer shows), the token file (one line, mode 0600, owned bysites-<target>) andsystemctl 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 tokeys(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-reloadedin the log); no restart needed. - Add
import /etc/caddy/sites.d/<target>/*.caddyto 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.