# Spillway CMS documentation (0.1.24) > Structured content like Drupal. Page building like Puck. Setup like Ghost. AI that drafts, people who approve. Spillway is a marketing CMS (TypeScript, Node 22): content types with typed fields and revisions, a visual page builder whose blocks render on the server, roles with drafts, review and an audit log, collections, forms with CRM connectors, localization, multisite, content releases, a module system with a WebAssembly sandbox, an MCP server for agents and a one-command launch on Fly.io. One process, SQLite or Postgres. During the private beta the server is proprietary software of KWALL LLC, used under a hosting plan or a beta agreement; the npm client packages (shared, blocks, sdk, client, astro, next, brand, create-spillway) are MIT. Anyone can build modules, themes, kits and front ends on Spillway with them, keep or sell what they build, and publish it to the registry under the license they choose. Index: https://spillwaycms.com/llms.txt # Getting started ## Install URL: https://spillwaycms.com/docs/install ## Install Spillway is one process: a Node server that serves the API, the admin and the public site, with SQLite and uploaded files in one data directory. Run it with Docker or from source. For more than one instance, or a managed database, point `DATABASE_URL` at Postgres instead (see [Postgres](#postgres)). During the private beta, running your own Spillway server takes a written agreement with KWALL LLC, such as a beta agreement, which comes with access to the image and the source; a Spillway hosting plan runs it for you ([licensing.md](dev/licensing.md)). Building on Spillway needs neither: modules, themes, kits and front ends are built with the MIT packages on npm ([modules.md](modules.md), [adapters.md](adapters.md)). ### Requirements - Docker: any recent Docker Engine or Docker Desktop. Nothing else. - From source: Node 22 or newer (`.nvmrc` pins 22; 24 works too) and pnpm 10. Node 22 ships corepack, so `corepack enable` installs the pnpm pinned in `package.json`; `npm install -g pnpm@10` is the alternative. The two native modules, `better-sqlite3` and `sharp`, download prebuilt binaries during `pnpm install` for macOS (Apple Silicon and Intel), Linux (x64 and arm64, glibc and musl) and Windows on Node 22 and 24, so no compiler is needed there. A C++ toolchain (Xcode Command Line Tools on macOS, `python3 make g++` on Debian) matters only when no prebuilt binary matches your platform or Node version. - About 200 MB of disk for the image, plus your data. - One CPU and 512 MB of RAM are enough for a marketing site. ### Docker ```bash docker run -d \ --name spillway \ -p 3000:3000 \ -v spillway-data:/data \ ghcr.io/kwall-llc/spillway-cms ``` Open http://localhost:3000/admin and complete the setup wizard (site name, your name, email, password). The image sets `DATA_DIR=/data`, `PORT=3000` and `HOST=0.0.0.0`, runs as the unprivileged `node` user, declares `/data` as a volume and has a Docker health check on `GET /healthz`. The database, uploads and the session secret all live in the `spillway-data` volume. Everything else uses the defaults in the table below. Pass `-e NAME=value` to change them. The `ghcr.io/kwall-llc/spillway-cms` image is the intended distribution channel. The release workflow (`.github/workflows/release.yml`) builds it for `linux/amd64` and `linux/arm64` on every `v*` tag and pushes it to GHCR under the repository's own name (`ghcr.io//`, lowercased) as `vX.Y.Z`, `X.Y` (the newest patch of that minor; it only ever moves forward, see [Taking patches automatically](#taking-patches-automatically)) and `latest` (the newest stable release of all; it also only moves forward); the GitHub release lists the digest. The canonical image name is [still an open decision](dev/open-decisions.md); this page and the README both say `ghcr.io/kwall-llc/spillway-cms` and change together. Pin `X.Y` to follow fixes without surprises, or the digest for a reproducible deploy. Until the first tag is published (see [docs/dev/releases.md](dev/releases.md)), build it yourself: ```bash docker build -t spillway . docker run -d -p 3000:3000 -v spillway-data:/data spillway ``` The `Dockerfile` is a two-stage build: the build stage installs all workspace dependencies and runs `pnpm run build`; the runtime stage installs only the production dependencies of `@spillway-cms/core` and copies the compiled `shared`, `blocks`, `core` and `admin` output. The result is a `node:22-bookworm-slim` image with no compilers left in it. ### Docker Compose `docker-compose.yml` in the repository root builds the image from the checkout. Abridged (the file also wires the optional `DATABASE_URL`, `REDIS_URL`, `SEARCH_URL` and `SEARCH_API_KEY` variables and defines the `postgres`, `redis` and `search` profiles described below): ```yaml services: spillway: build: . image: spillway:local ports: - "3000:3000" environment: PORT: "3000" DATA_DIR: /data BASE_URL: ${BASE_URL:-http://localhost:3000} # SESSION_SECRET: change-me LOG_LEVEL: info volumes: - spillway-data:/data restart: unless-stopped volumes: spillway-data: ``` ```bash docker compose up -d # builds on first run BASE_URL=https://www.example.org docker compose up -d # behind a TLS proxy ``` To use a published image instead of building, replace `build: .` and `image: spillway:local` with `image: ghcr.io/kwall-llc/spillway-cms`. The file also holds the `updater` and `docker-proxy` services, under the `updater` profile, for [one-click updates](#one-click-updates) from the admin. They start only with `--profile updater`. ### From source ```bash git clone https://github.com/kwall-llc/spillway-cms.git cd spillway-cms corepack enable # once per machine: installs the pnpm version pinned in package.json pnpm preflight # checks Node, pnpm, the native modules, the data folder and the port, and says what to run next pnpm install pnpm build pnpm start ``` Open http://localhost:3000/admin. The first visit lands on the setup wizard (site name, your name, email, a password of at least 8 characters); "Create site" signs you in and opens the dashboard. Until that first admin exists, every other admin URL redirects to `/admin/setup`. Budget about five minutes from clone to dashboard on a laptop: `pnpm install` takes under a minute on a normal connection, `pnpm build` about half a minute, the server starts in a second. What each step does: - `corepack enable` makes the `pnpm` command available and, on first use, downloads the exact version from `packageManager` in `package.json`. Skip it if `pnpm --version` already prints 10.x. - `pnpm preflight` (`scripts/doctor.mjs`; not `pnpm doctor`, which is pnpm's own command) is optional and safe to run at any point; it fails only when Node is older than 22, pnpm is missing or older than 10, a native module does not load, or the data folder is not writable, and it warns when the port is taken or the build is missing. - `pnpm install` installs every workspace package. The two native modules run their install scripts (`package.json` allowlists them under `pnpm.onlyBuiltDependencies`, so pnpm 10 does not print its "Ignored build scripts" warning for them): `better-sqlite3` downloads a prebuilt binary from its GitHub release, `sharp` installs the prebuilt `@img/sharp-*` package for your platform. Both are plain downloads; see [Native modules](#native-modules) if one fails. - `pnpm build` builds `shared`, `blocks`, `admin` (Vite, into `packages/admin/dist`), `core` (tsc, into `packages/core/dist`) and the `sdk` and `docs-tools` packages. The one warning it prints, "Some chunks are larger than 1200 kB", is Vite commenting on the admin bundle size and is expected. - `pnpm start` runs `scripts/start.mjs`, which loads `.env` when there is one and then starts `packages/core/dist/server.js` (running that file with `node` directly is the same without the `.env` step). The server applies the migrations, serves the admin from `packages/admin/dist`, and writes the database, uploads and session secret to `./data`. The one log line it prints, `Spillway 0.1.0 listening`, shows the URL, the data folder and `"installed": false` until the wizard has run. Stop it with Ctrl+C. `pnpm quickstart` runs `pnpm install && pnpm build && pnpm preflight` in one go. `pnpm spillway ` runs the CLI (see [The `spillway` command](#the-spillway-command)). Copy `.env.example` to `.env` to change the port or the data folder; see [Environment variables](#environment-variables). For the development loop with hot reload see [dev/contributing.md](dev/contributing.md). Two things a first run can also do: - **Create the first admin from the terminal** instead of the wizard: `pnpm spillway create-user --email you@example.org --password 'at least 8 characters' --name 'You'` (add `--site-name 'Acme'` to name the site). This creates the site and the user and marks the install as done, so `/admin` goes straight to the login screen. - **Protect the wizard** when the server is reachable by other people before you get to it (a shared host, a port forwarded through a firewall): start it with `SETUP_TOKEN=`; the wizard then has a "Setup token" field and `POST /api/setup` refuses requests without it. The token does nothing once the first admin exists. Set `NODE_ENV=production` for a real deployment (the Docker image does): React then renders pages with its production build instead of the development build and its per-element checks, which is a quarter of the time a page takes to render ([dev/benchmarks.md](dev/benchmarks.md)). If `/admin` answers 503, the admin bundle is missing: run `pnpm --filter @spillway-cms/admin build` (or `pnpm build`). If `pnpm start` fails with `Cannot find module '.../packages/core/dist/server.js'`, `pnpm build` has not run yet. If the port is taken, `PORT=3001 pnpm start`. #### macOS On a Mac (Apple Silicon or Intel) the steps above work as written once Node 22 is installed. Two ways to get it: - Homebrew: `brew install node@22`. The formula is keg-only, so add it to your `PATH` as `brew` tells you (`echo 'export PATH="$(brew --prefix node@22)/bin:$PATH"' >> ~/.zshrc`, then open a new terminal). It includes corepack, so `corepack enable` then works. - nvm: `nvm install 22 && nvm use 22`; the checkout's `.nvmrc` lets `nvm use` pick it up later. Then `corepack enable` (or `npm install -g pnpm@10`). You do not need the Xcode Command Line Tools for Spillway itself: `better-sqlite3` 12.x and `sharp` 0.35 ship prebuilt `darwin-arm64` and `darwin-x64` binaries for Node 22 and 24, and `pnpm install` downloads them. If you see `node-gyp` output or an error mentioning `make` or `clang`, the prebuilt download failed (a proxy, an unusual Node version): install the tools with `xcode-select --install` and run `pnpm rebuild better-sqlite3`, or see [Native modules](#native-modules). #### Native modules `better-sqlite3` and `sharp` are the only packages with platform-specific binaries. - `better-sqlite3` runs `prebuild-install` during `pnpm install`, which downloads `better-sqlite3-v-node-v--.tar.gz` from the package's GitHub releases; if that fails it falls back to `node-gyp rebuild`, which needs Python 3 and a C++ compiler. Behind a proxy that blocks `github.com`, set `HTTPS_PROXY`, or install the compiler. - `sharp` has no install script: `pnpm install` picks the matching `@img/sharp--` and `@img/sharp-libvips-*` packages from the lockfile, which cover macOS, Linux and Windows. - pnpm 10 only runs install scripts for packages listed under `pnpm.onlyBuiltDependencies` in `package.json`; `better-sqlite3` and `esbuild` are listed, so there is nothing to approve. If a future dependency adds one, `pnpm install` prints "Ignored build scripts" and `pnpm approve-builds` lets you allow it. - `pnpm preflight` loads both modules and prints the SQLite and libvips versions; `pnpm rebuild better-sqlite3` rebuilds it in place after a Node upgrade (the binary is tied to the Node major version). ### Environment variables All are optional. The first table is what the server reads (`packages/core/src/config.ts`, plus the few that other modules read directly, each marked). From a source checkout, `pnpm start` and `pnpm spillway` also read a `.env` file in the repository root (`.env.example` lists the common ones with their defaults); `node packages/core/dist/server.js` on its own reads only the shell environment. In Docker Compose, a `.env` next to `docker-compose.yml` fills the `${...}` placeholders. | Variable | Default | What it does | | --- | --- | --- | | `PORT` | `3000` | Port to listen on. | | `DATA_DIR` | `./data` (`/data` in the image) | Directory for the SQLite file, the `media/` upload folder and the `session-secret` file. Created on first boot. | | `DATABASE_URL` | `/spillway.db` | Where the database lives. A bare file path or `sqlite:` is a SQLite file (`:memory:` gives a throwaway in-memory database, used by tests); `postgres://user:pass@host:5432/db` or `postgresql://...` switches the whole server to Postgres. See [Postgres](#postgres). | | `DATABASE_POOL_MAX` | `10` | Postgres only: size of the connection pool per server process. | | `SESSION_SECRET` | generated | Key used to hash session tokens before they are stored. If unset, a random secret is generated on first boot and saved to `/session-secret` (mode 0600), so sessions survive restarts. Set it explicitly when you run more than one container against the same data. At least 32 characters. | | `BASE_URL` | unset | Public origin of the site, for example `https://www.example.org`, no trailing slash. When it starts with `https://` the session cookie is marked `Secure` (with the `__Host-` prefix) and HSTS is sent; a trusted proxy's `X-Forwarded-Proto: https` does the same (see [Reverse proxy](#reverse-proxy)). Also used for absolute URLs, including the links in invite and password reset emails. Set it in production; on Render, Railway and Fly the platform's address is used until you do. | | `REDIRECT_HOSTS` | unset | Other names of the site, comma or space separated, such as `example.org` next to `BASE_URL`'s `www.example.org`, or a hosting platform's address once the site has its own domain. Requests to them get a redirect to `BASE_URL` with the path and query kept (301 for GET and HEAD, 308 otherwise), so visitors and search engines land on one address. `/healthz` still answers on them, for the host's checks. Point each name's DNS at the server first. | | `RENDER_EXTERNAL_URL`, `RAILWAY_PUBLIC_DOMAIN`, `FLY_APP_NAME` | set by the platform | Used as the public address when `BASE_URL` is unset (see [One-click deploys](#one-click-deploys)). | | `ADMIN_DIST` | `packages/admin/dist` relative to the core package | Folder holding the built admin SPA. Change it only if you build the admin elsewhere. | | `LOG_LEVEL` | `info` | One of `debug`, `info`, `warn`, `error`, `silent`. Warnings and errors go to stderr, the rest to stdout. | | `HOST` | `0.0.0.0` | Interface to bind. Read in `server.ts`. | | `SMTP_URL`, `SMTP_FROM` | unset | Optional: the mail relay for form email connectors and notification rules, e.g. `smtp://user:pass@smtp.example.org:587?from=cms@example.org` (`smtps://` for implicit TLS; `SMTP_FROM` is an alternative to `?from=`). Without it the relay set in the admin under **Site settings → Mail** is used; when it is set it wins and the Mail tab is read-only. With neither, mail is logged instead of sent. See [Mail](#mail). | | `SPILLWAY_TICKER` | `1` | The in-process clock that publishes scheduled content, merges scheduled content releases, runs import jobs, polls translation jobs, embeds pages for search by meaning, starts due agent tasks and delivers notifications every 30 s (and, hourly, prunes expired sessions, old audit rows and old 404 log entries). Set `0` when several server processes share one database and let cron run `spillway run-scheduled` instead. Read in `server.ts`. | | `AGENT_CONCURRENCY` | `2` | How many agent task runs one server process runs at a time; due tasks beyond it wait for the next tick. Each run makes model calls for up to ten minutes. Read in `agents/tasks.ts`. | | `TRUSTED_PROXIES` (read in `auth/client-ip.ts`) | unset | Which peers may speak for the visitor through `X-Forwarded-For`: a comma-separated list of addresses or CIDRs (`10.0.0.0/8, 172.16.0.0/12`), the words `loopback` or `private`, `fly` (Fly.io's edge, which sets `Fly-Client-IP`; a peer on Fly's private network, `fdaa::/16`, is not trusted unless listed too), `cloudflare` (Cloudflare's edge in front of the rest: when the address the other proxies saw is Cloudflare's, `CF-Connecting-IP` is the client and `CF-Visitor` the scheme), or `*` (every direct peer; only when a proxy is the sole route to the port). Unset, the socket address is the client, which behind a proxy means every visitor shares one rate-limit bucket. See [Reverse proxy](#reverse-proxy). | | `CLOUDFLARE_IPS` (read in `auth/client-ip.ts`) | Cloudflare's published ranges, bundled | The ranges `TRUSTED_PROXIES=cloudflare` treats as Cloudflare's edge, comma or space separated, in place of the list bundled with the release (dated in `CLOUDFLARE_RANGES_AS_OF`). Set it only if Cloudflare adds a range before you upgrade: copy and . | | `CDN_PROVIDER` (read in `hosting/host.ts`) | unset | `host`: a hosting platform runs the CDN in front of the site and purges it for the site through `HOST_API_URL` with `HOST_API_KEY`, so the site holds no CDN token. Needs `CDN_TAG_PREFIX`. Sites with a provider of their own under Site settings → Cache keep it. The platform sets this; see [caching.md](caching.md#the-hosting-platforms-cdn). | | `CDN_TAG_PREFIX` (read in `hosting/host.ts`) | unset | With `CDN_PROVIDER=host`: the name the platform gives the site (letters, digits, `.`, `-`, `_`). Every cache tag the site sends, in `Cache-Tag` and in its purges, becomes `:`, so a CDN shared by many sites keeps them apart. | | `REQUIRE_TWO_STEP` (read in `config.ts`) | unset | `admins` or `all`: who must use two-step sign-in on every site of the instance, as a floor Site settings → Security can raise but not lower (`admins` is people with the admin role or `users.manage` on the site; `all` is everyone who signs in to the admin). Someone it applies to who has not turned it on is signed in only to the enrollment page. Single sign-on (SAML, OIDC, CAS) and the hosting platform's sign-in are not held to it. Any other value stops the server at start. See [security.md](security.md#two-step-sign-in). | | `ADMIN_IP_ALLOWLIST` (read in `config.ts`) | unset | IPv4 and IPv6 addresses and CIDR ranges, comma or space separated (`203.0.113.0/24, 2001:db8::/32`): the admin, its sign-in and every API call made with a session or an API token answer only these addresses, on every site (a site's own list under Site settings → Security applies too). An entry that is not an address or a range stops the server at start. Set `TRUSTED_PROXIES` first behind a proxy, or every visitor has the proxy's address. See [security.md](security.md#admin-ip-allowlist). | | `SETUP_TOKEN` (read in `routes/setup.ts`) | unset | When set, `POST /api/setup` (the first-admin wizard) needs the same value in the `X-Setup-Token` header; the wizard screen asks for it. `deploy/fly/launch.sh` and the one-click deploys generate one, so a new site cannot be claimed by a stranger before setup runs. Unset it (or leave it) once the site is set up; it does nothing afterwards. | | `SPILLWAY_TRUSTED_MODULE_INSTALL` (read in `modules/system.ts`) | unset | `1` lets an admin install or enable trusted-tier (in-process JavaScript) modules from the admin. Off by default: see the [trust model](modules.md#trust-model). | | `SPILLWAY_ALLOW_PRIVATE_URLS` (read in `forms/http.ts`) | unset | `1` lets webhooks, notification channels, AI base URLs and module HTTP calls reach private network addresses (an internal CRM behind the firewall). Off by default: outbound requests to loopback, link-local, RFC 1918 and other private ranges are refused. See [security.md](security.md). | | `SPILLWAY_SAFE_MODE` (read in `modules/system.ts`) | unset | `1` boots without loading any module (same as `--safe-mode`). | | `SPILLWAY_CAPTCHA_VERIFY_URL` (read in `forms/captcha.ts`) | unset | Test hook: where CAPTCHA tokens are verified instead of the provider's siteverify endpoint (the test suite runs a local fake). Leave unset in production; the provider and keys are set under Site settings → Forms. | | `SPILLWAY_HUBSPOT_FORMS_URL` (read in `forms/connectors/hubspot.ts`) | `https://api.hsforms.com/submissions/v3/integration/submit` | Test hook: where the HubSpot form connector posts. Leave unset in production. | | `SMTP_URL`, `SMTP_FROM` | | See above; read in `mail/settings.ts` (`resolveMail`), which both senders use. | | `SMTP_DEFAULT_URL`, `SMTP_DEFAULT_FROM` | unset | Optional: a host's relay, used until the site's admin sets one under **Site settings → Mail** (theirs replaces it; the tab stays editable). See [Mail](#mail). | | `HOST_SIGNIN_URL`, `HOST_SIGNIN_PROVIDERS`, `HOST_SITE_ID` | unset | Set by a hosting platform that offers a shared Google and Microsoft sign-in for its sites' account pages: the sign-in service's address (https), the providers it offers (`google`, `microsoft` or `google,microsoft`) and the site's id there. With these and `HOST_API_KEY`, **Continue with Google** and **Sign in with Microsoft** work without an app of the site's own. See [Hosted sign-in](#hosted-sign-in). | | `HOST_API_URL`, `HOST_API_KEY`, `HOST_AI_MODEL` | unset | Set by a hosting platform for the sites it runs: the site's endpoint on the platform (https) and its key. With both, AI runs through the host's metering proxy (`/ai/anthropic`, paid with the plan's AI credits) whenever a provider has no key of the site's own, AI starts switched on, and **Site settings → Usage and plan** shows the plan and this period's usage, with the **Hosting** card (status, backups, version, update window) there and on the dashboard. `HOST_AI_MODEL` picks the host's model. See [Hosted sites](#hosted-sites). | | `KITS_DIR` | unset | A folder of kits (`//kit.json`) offered under Kits instead of the bundled `packages/kits`. | | `REDIS_URL` | unset | `redis://host:6379/0` (or `rediss://`) moves the page cache to Redis so several app instances share one cache and evict each other's entries; each instance keeps a small local LRU in front. The server pings Redis at startup and refuses to start when it does not answer within 3 seconds. Unset: the in-process cache. See [Scaling out](#scaling-out-redis-and-meilisearch). | | `REDIS_PREFIX` | `spillway:` | Key prefix in Redis, so several sites can share one server. | | `SPILLWAY_COMMIT`, `SPILLWAY_CHANNEL`, `SPILLWAY_BUILT_AT` | set by the image build | Which build this is, for Admin → Updates and `/status`: the commit, `main` or `release`, and the build time (ISO 8601). The Dockerfile takes them as build arguments of the same names (`docker build --build-arg SPILLWAY_COMMIT=$(git rev-parse HEAD) --build-arg SPILLWAY_CHANNEL=main --build-arg SPILLWAY_BUILT_AT=$(date -u +%FT%TZ) .`); the release workflow sets them. Unset, only the version number is compared. | | `SPILLWAY_EMBED_MODEL_DIR` | `/app/models` in the image | Where search by meaning finds its model (`//config.json` and `onnx/model_quantized.onnx`). The image ships all-MiniLM-L6-v2 there; built with `--build-arg EMBED_MODEL=0` it does not, and search is keyword only. Outside the image the default is `models/` at the checkout's root. | | `SPILLWAY_EMBED_MODEL` | `Xenova/all-MiniLM-L6-v2` | The embedding model. `Xenova/multilingual-e5-small` serves sites in other languages better but needs about 450 MB of memory instead of about 100 MB; pages are re-embedded after a change. | | `SPILLWAY_EMBED_DUTY` | `0.2` | The share of one CPU core the background embedding may use (0.05 to 1). It rests between pages for the time it worked, scaled, so the first indexing of a large site never slows requests; on a shared-CPU machine, full speed spends the burst budget and throttles everything. The model also runs on one thread. Raise it on dedicated CPUs to index faster. | | `SPILLWAY_EMBED_DOWNLOAD` | unset | `1` lets the server download a model it does not find in `SPILLWAY_EMBED_MODEL_DIR` from Hugging Face into `/models` (development, or a model not in the image). | | `SEARCH_URL`, `SEARCH_API_KEY` | unset | `http://host:7700` and an API key switch site search to Meilisearch (one index per site, typo tolerance, facets by type and term). Unset: SQLite FTS5 or Postgres full-text search. Run `spillway search reindex` (or `POST /api/search/reindex`) after setting it. | | `SPILLWAY_RENDERER_URL`, `SPILLWAY_RENDERER_TOKEN` | unset | The screenshot renderer for Migrate a site's visual comparison and for Import from Storybook, such as `http://renderer:3200` (and the bearer token it requires, when it requires one): see [The screenshot renderer](#the-screenshot-renderer). Unset: Review shows the original and the new page side by side in frames, and the score leaves the visual part out; Import from Storybook drafts from each story's name, args and description without a screenshot. | | `SPILLWAY_MODULE_BUILDER` | unset | The command that builds the code of a module generated for a migration's gap, instead of Spillway's own isolated builder (a Node process with no network, reading only the AssemblyScript toolchain). It reads the sources as JSON on stdin and answers the `.wasm` as JSON on stdout, like the built-in one: for example a container run with no network. See [security.md, Generated modules](security.md#generated-modules). | | `BACKUP_TARGET` | unset | Where backups go: `s3://bucket/prefix` (any S3-compatible store: AWS S3, Cloudflare R2, Tigris, MinIO) or a directory (a mounted volume, a second disk). The default target of `spillway backup` and the target of scheduled runs and **Run now**. Unset: no scheduled backups. See [Backups](#backups). | | `BACKUP_SCHEDULE` | unset | When the ticker backs up, in UTC: `hourly` (`hourly@MM` for another minute), `daily` (03:00; `daily@HH` or `daily@HH:MM`) or `weekly` (Sunday 03:00; `weekly@HH`, `weekly@mon`, `weekly@mon 04:30`). Needs `BACKUP_TARGET`. Unset: backups run only by hand. | | `BACKUP_RETENTION_DAYS` | `30` | Once a day, after a run, runs older than this are deleted from the target (the newest is always kept), then the media files no remaining run names. `0` keeps everything. | | `BACKUP_MONTHLY_RETENTION_DAYS` | `0` | Keeps each UTC month's first scheduled run (the first that finished, when one failed) this many days, past `BACKUP_RETENTION_DAYS`: a monthly backup. `0`, or a value no longer than the retention, keeps no runs beyond the retention. See [Backups](#backups). | | `BACKUP_ENCRYPTION_KEY` | unset | Encrypts every backup member with AES-256-GCM (the database, the instance key files, modules, form uploads): 64 hex characters (`openssl rand -hex 32`) or a passphrase. Strongly recommended: backups carry the key files that decrypt every stored credential, so without it they sit in clear on the target (the run is flagged `unencrypted_secrets` and `/status.json` reports `backup_unencrypted`). Keep it outside the instance and outside the backup: without it nothing can be restored. Media files are stored in clear (they are public once published). | | `BACKUP_S3_ENDPOINT`, `BACKUP_S3_REGION`, `BACKUP_S3_ACCESS_KEY_ID`, `BACKUP_S3_SECRET_ACCESS_KEY` | AWS S3, region `auto` | The S3-compatible endpoint and credentials for an `s3://` target. R2: `https://.r2.cloudflarestorage.com`; Tigris: `https://fly.storage.tigris.dev`; AWS: leave the endpoint unset and set the bucket's region. `AWS_ENDPOINT_URL_S3`, `AWS_ENDPOINT_URL`, `AWS_REGION`, `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` (what `fly storage create` sets) are read when these are unset. | | `MEDIA_STORAGE` | unset | `s3://bucket/prefix` keeps the media library's files in an S3-compatible bucket (Cloudflare R2, Tigris, AWS S3, MinIO) instead of on the disk, with `/media` as a cache of them. The files keep their `/media/...` addresses. Unset (or `local`): the disk. Any other value stops the server at start. See [Media on object storage](#media-on-object-storage). | | `MEDIA_S3_ENDPOINT`, `MEDIA_S3_REGION`, `MEDIA_S3_ACCESS_KEY_ID`, `MEDIA_S3_SECRET_ACCESS_KEY` | AWS S3, region `auto` | The endpoint and credentials for `MEDIA_STORAGE`, as for `BACKUP_S3_*` (the `AWS_*` names are read when these are unset). Without credentials the server stops at start. | | `MEDIA_CACHE_MB` | `2048` | With `MEDIA_STORAGE`: how much of the disk the media cache may fill; past it, the least recently used files are dropped until it is at 80%. `0` keeps every file on the disk too. | | `MEDIA_DELETE_AFTER_DAYS` | `0` | With `MEDIA_STORAGE`: a deleted file (and the old file of **Replace file**) stays in the bucket this many days before the server removes it, unless a media item names it again by then. Set it to how far back you restore the database from snapshots of its own (a volume snapshot, a managed database's), so a restored database still finds its files. `0` removes them at once. | | `STATUS_PAGE` | on | `off` (or `0`) turns the public [status page](#status) (`/status` and `/status.json`) off; both answer 404. | | `STATUS_PROBE_URLS` | unset | Comma-separated instance URLs the status probe records every five minutes for a StatusBoard's 90-day uptime bar, in addition to the URLs published StatusBoard blocks name. See [Status](#status). | | `REGISTRY_URL` (read in `modules/`) | `https://spillwaycms.com/registry/v1/index.json` | The registry index (modules, kits and themes); the default is the public registry on spillwaycms.com. `https://` or `file://`; plain `http://` is refused unless `REGISTRY_ALLOW_HTTP=1` (development only). | | `REGISTRY_PUBLIC_KEY` | the spillwaycms.com key with the default `REGISTRY_URL`, otherwise unset | Base64 ed25519 public key (the `public.txt` from `spillway registry keygen`). When set, a registry index without a valid `signature` is refused, so a compromised CDN cannot swap tarballs and checksums together. The default registry's key is built in, so a site on the default `REGISTRY_URL` checks signatures without setting anything; `REGISTRY_PUBLIC_KEY=` (empty) turns the check off. See [modules.md](modules.md#publishing-to-the-registry). | | `REGISTRY_ALLOW_HTTP` | unset | `1` allows a plain `http://` registry URL and tarballs. Never in production. | | `MCP_PUBLIC` | unset | `read` turns public read-only MCP access on for every site of the instance; `off` keeps it off whatever a site's setting says; unset leaves it to Site settings → SEO ([mcp.md](mcp.md#public-read-only-access)). | | `REGISTRY_SOURCES` | unset | More registries read before `REGISTRY_URL`, such as your organization's own: a JSON array of `{ "id", "label", "url", "publicKey"?, "scopes"?, "supplies"? }`. `supplies` lists what the source may supply (`sandboxed`, `trusted`, `kit`, `theme`, `brand`, `components`; all six when left out). A source with `scopes` (such as `["@acme"]`) is the only place packages in those scopes come from, and serves nothing else; any other name comes from the first source without scopes that lists it. `REGISTRY_URL=off` leaves the public registry out. A malformed list stops the server at startup. These sources are read-only in the admin and win over the ones added there. See [registry.md](registry.md#several-registries). | | `REGISTRY_URL_SUPPLIES` | unset | What the `REGISTRY_URL` source may supply, comma-separated (`sandboxed,kit,theme,brand,components` keeps trusted modules to your own registries). Unset: all six, or what System → Modules → Registries sets. | | `REGISTRY_LOCKDOWN` | unset | Locked-down mode: comma-separated source ids (`acme,mirror`, or `spillway` for `REGISTRY_URL`), the only registries listed, installed from and checked for updates; the others are not read. Wins over the setting in System → Modules → Registries. See [registry.md](registry.md#locked-down-mode). | | `REGISTRY_MIRROR_DIR` | unset | Registry hosts only: a folder made with `spillway registry mirror`, served read-only at `/registry/v1/mirror/index.json` and its tarballs. See [registry.md](registry.md#mirroring). | | `REGISTRY_MAX_INDEX_AGE_DAYS` (read in `modules/registry-client.ts`) | `30` | With `REGISTRY_PUBLIC_KEY` set, a signed index older than this is refused as `registry_stale`; `0` turns the check off. See [security.md](security.md#the-package-registry). | | `DOCS_DIR` (read in `marketing/seo.ts`) | `docs/reference` next to the packages | Folder holding the generated `llms-full.txt` and `openapi.json` (written by `pnpm docs:build`), served at `/llms-full.txt` (when the site's `llms.txt` is on) and `/openapi.json`. A missing file answers 404. | | `REGISTRY_HOST` | unset | `1` runs this instance as a package registry (`/registry/v1/*`, `/api/registry/*`): publishing, the signed index, review. See [registry.md](registry.md). | | `REGISTRY_SIGNING_KEY` | unset | Registry hosts only: path of the ed25519 private key PEM (`spillway registry keygen`) that signs `/registry/v1/index.json`. | | `REGISTRY_STORAGE` | `/registry` | Registry hosts only: where published tarballs are stored. | | `REGISTRY_FOUR_EYES` | unset | Registry hosts only: `1` makes approving a trusted module version refuse the person who published it, the package's publisher and its namespace's maintainers (`403 four_eyes`). See [registry.md](registry.md#review-policy). | | `REGISTRY_CORE_IMAGES` (read in `updates/images.ts`) | unset | Registry hosts only: path of the `core-images.json` the release workflow attaches to every GitHub release (each release's image digest). The core feed lists them as `images` and the host signs the feed with `REGISTRY_SIGNING_KEY`; [one-click updates](#one-click-updates) install only a digest listed there. A file that does not read stops the start. | | `SPILLWAY_UPDATER_URL`, `SPILLWAY_UPDATER_SECRET` (read in `updates/one-click.ts`) | unset | The Docker updater for [one-click updates](#one-click-updates): its address on the compose network (`http://updater:3100`) and the secret it shares with this server (at least 32 characters). With the URL and no secret the server calls nothing and Admin → Updates says why. The standard `docker-compose.yml` sets the URL whenever the secret is set. | | `SPILLWAY_DEPLOY_HOOK_URL` (read in `updates/one-click.ts`) | unset | The service's Render deploy hook (`https://api.render.com/deploy/srv-...?key=...`, under the service's **Settings** on Render): [one-click updates](#one-click-updates) call it with the release's image digest. Keep it secret: anyone with it can deploy the service. | | `SPILLWAY_FLY_API_TOKEN` (read in `updates/fly.ts`) | unset | On Fly.io, a deploy token for the app (`fly tokens create deploy`), set as a Fly secret: [one-click updates](#one-click-updates) set the image of the Machine the server runs on through the Machines API. Fly's own `FLY_APP_NAME` and `FLY_MACHINE_ID` name the app and the Machine. Keep it secret: anyone with it can deploy the app. | | `SPILLWAY_UPDATER_HEALTH_TIMEOUT` (read in `updates/one-click.ts`) | `300` | On Fly, the seconds the new version of a [one-click update](#one-click-updates) has to start (migrations included) before it asks Fly for the previous image. The Docker updater reads the same variable on its own service. | | `SPILLWAY_READ_ONLY` | unset | Makes the instance read-only: every change by a signed-in user (a session or an API token) answers `423` with code `read_only` and this value as the reason (`1` gives a generic one), while reading, exporting, signing in and the public site with its forms and accounts keep working. The admin shows the reason in a banner. A hosting provider can set it, for example on a site whose payment is overdue or that was cancelled. `0` or unset turns it off. | | `SPILLWAY_OUTBOUND` | `on` | `off` for a copy that must not act on the outside world: a staging copy, a preview, a restored copy someone is inspecting. The admin and the public pages work as usual, but form connectors, payments and module form actions do not run, no mail or notification is sent, module HTTP is refused, AI runs only through the host's AI, CDN purges are skipped and tracking tags are left out of pages. Each held-back action is audited as `outbound.suppressed`. Any value other than `on` or `off` (also `1`, `true`, `yes` and `0`, `false`, `no`) stops the start. See [Copies of a site](#copies-of-a-site). | | `SITE_LOCK_PASSWORD` | unset | Locks every site on the instance behind this password: visitors get a password page, anyone signed in to the admin passes, tools can use HTTP Basic auth with it. For staging and development environments, so a copy of the production database cannot leave them open; it overrides each site's Site settings → Site lock. See [getting-started.md](getting-started.md#site-lock). | | `SPILLWAY_REGISTRY`, `SPILLWAY_REGISTRY_TOKEN` (read in `cli.ts`) | unset | Defaults for `spillway publish --registry` and `--token`, and for `spillway kit install --registry`. | | `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `XAI_API_KEY`, `OPENAI_COMPATIBLE_API_KEY` | unset | Fallback AI provider keys when none is stored under Site settings → AI. See [api.md](api.md#ai). | | `NODE_ENV` | unset | `test` lifts the outbound private-network guard and `development` allows a local `http://127.0.0.1` AI base URL; leave unset or `production` in production. | Enterprise sign-in (OIDC and SAML with Okta, Entra ID, Google Workspace, Shibboleth/InCommon, Login.gov) needs no environment variable: providers are configured under Site settings → Sign-in, and the OIDC client secrets are encrypted with a key generated into `/sso-secret` (mode 0600, keep it with your backups). `BASE_URL` must be set so the redirect, ACS and metadata URLs handed to the identity provider match the public address. See [sso.md](sso.md). ### Postgres SQLite is the default and is right for one instance on one disk. Postgres is for running more than one instance, for a managed database with its own backups, or when the site should not live on a volume. Everything behaves the same on both: the same migrations, the same API, the same site search (FTS5 on SQLite, `tsvector` with a GIN index on Postgres). Postgres 14 or newer; 17 is what CI and the compose profile use. Switch by setting `DATABASE_URL` to a connection URL: ```bash DATABASE_URL=postgres://spillway:secret@db.internal:5432/spillway ## TLS as the driver understands it: ?sslmode=require, ?ssl=true, or sslrootcert=... on the URL ``` `DATA_DIR` is still needed: uploads and the generated secrets live there. Migrations run on boot as before, or ahead of time with `spillway migrate`: ```bash DATABASE_URL=postgres://... node packages/core/dist/cli.js migrate ``` #### Docker Compose with Postgres `docker-compose.yml` has an optional `postgres` service (`postgres:17`, with a health check and its own volume) behind the `postgres` profile: ```bash DATABASE_URL=postgres://spillway:spillway@postgres:5432/spillway docker compose --profile postgres up -d ``` Change `POSTGRES_PASSWORD` (and the URL) before exposing anything. Without the profile and without `DATABASE_URL`, compose runs SQLite in the `spillway-data` volume as before. #### Fly Postgres ```bash fly postgres create --name my-spillway-db fly postgres attach my-spillway-db --app my-spillway # sets DATABASE_URL as a secret fly deploy ``` `fly postgres attach` sets `DATABASE_URL` to a `postgres://` URL on the private network, which is all Spillway needs. Keep the `/data` volume for uploads, or move media to object storage when that lands. With Postgres you can run more than one machine behind Fly's proxy; the in-process page cache is per machine, so each one warms separately. #### Moving a site from SQLite to Postgres `spillway export` and `spillway import` carry the sites, content types, entities, revisions, users, media metadata, vocabularies with their terms, menus, collections and form definitions between databases ([Copying a site with export and import](#copying-a-site-with-export-and-import)): ```bash ## 1. From the SQLite install (DATABASE_URL unset or pointing at the file) node packages/core/dist/cli.js export spillway-export.json ## 2. Against the new database DATABASE_URL=postgres://... node packages/core/dist/cli.js migrate DATABASE_URL=postgres://... node packages/core/dist/cli.js import spillway-export.json ## 3. Rebuild the search index once the server is up (POST /api/search/reindex as an admin), then ## start the server with DATABASE_URL set. ``` Imported users get a random unusable password (the export never carries hashes), so reset them with `spillway set-password` (the password on stdin) or in the admin. Copy `DATA_DIR/media` across unchanged; the export holds media metadata, not the files. Form submissions, redirects, notification rules, shared blocks, placements and the other tables are not part of the export; recreate them in the admin. Moving the whole database, those included, is `spillway backup` and `spillway restore` on SQLite or `pg_dump` and `pg_restore` on Postgres ([Backups](#backups)). #### Copying a site with export and import `spillway export ` writes a JSON file (version 2) with every site's settings, the content types, entities and their revisions, users (without password hashes), media metadata, vocabularies with their terms (parents first), menus, collections and form definitions. Submissions are never in it, and neither are webhook secrets: a copy is not a secret store. `spillway import ` applies it to a database inside one transaction, item by item: - an id the database does not have is **added** under the same id, so everything that names it (a taxonomy field naming a term, a menu linking a page, a collection filtering by a term, the site's home page) still points at it; - an id it has is **updated** when it differs and left **unchanged** when it does not, so running the same import twice changes nothing the second time; - a key it has under another id (a vocabulary or site by key; a menu, collection or form by key within its site; a term by slug under the same vocabulary and parent; a page at the same path, such as the home page a new site starts with) is mapped onto that row: the row is updated in place and keeps its id, and every reference to the file's id in what is imported is rewritten to it. Revisions of such a page keep the target's history and are numbered after it; - users are added by email and never changed; a user whose email exists keeps their account, and what the file attributes to them is attributed to it; - revisions and media metadata are added when new; - a webhook connector without a secret keeps the secret the database has for the same URL; - what each imported page links to and the terms it is tagged with are rebuilt from its data. `--dry-run` does all of that and rolls it back, then lists what would be added, updated or unchanged per section and every item that would be added or updated (with `->` and the target's id for a mapped one); `--json` prints the full report, every item included. A real import writes one `export.import` audit row with the counts. ```bash spillway export prod.json # on the source spillway import prod.json --dry-run # on the target: what would change spillway import prod.json # apply it, then copy media/ and rebuild the search index ``` Files written before version 2 (site, types, entities, revisions, users and media only) still import; a file from a newer Spillway is refused with a message to upgrade first. To carry only the structure between sites in git, use **Kits → Export structure** instead ([kits.md](kits.md#structure-export-and-import)). #### Backups on Postgres `spillway backup --to` runs `pg_dump --format=custom` when the PostgreSQL client tools are on `PATH` (the official image carries `pg_dump` and `pg_restore` 17, which work with servers up to Postgres 17; for a newer server build the image with `--build-arg PG_CLIENT=18`, or elsewhere install the same major version as the server, for example `apt-get install postgresql-client-17`) and stores the dump with the key files, modules, form uploads and media like a SQLite run. Without `pg_dump` the run fails, and the error prints the exact command to run where the tools are (the password is left out: pass it as `PGPASSWORD`). A Postgres run is restored with `pg_restore`: `spillway restore` downloads and verifies it, saves the dump under `DATA_DIR/backups/`, puts the key files, modules and (with `--media`) files back, and prints the command. Managed snapshots hold the database only: the key files in `DATA_DIR` still need a backup run (or a copy of their own) for the stored credentials to decrypt. Managed Postgres (Fly, RDS, Neon) also keeps its own snapshots. `spillway export` works the same on both dialects. See [Backups](#backups). ### Scaling out: Redis and Meilisearch One Spillway process serves a site comfortably; for several instances behind a load balancer, or for a bigger search corpus, two optional services plug in: - **Redis page cache** (`REDIS_URL`). Rendered pages live in Redis under `REDIS_PREFIX` with their tags (`spillway:page:`, `spillway:tag:`); a publish on any instance deletes the tagged entries in one pipeline and publishes the tags on `spillway:invalidate`, and every instance evicts them from its local LRU (200 entries in front of Redis). Entries expire after 24 hours at most, listings and search results after a minute. Point every instance at the same Redis and the same `DATABASE_URL`, set `SESSION_SECRET` explicitly, and set `SPILLWAY_TICKER=0` on all but one of them. Memory: `maxmemory` with `allkeys-lru` keeps Redis bounded; the compose file's `redis` profile does that. Startup checks the connection: when the server at `REDIS_URL` does not answer a ping within 3 seconds (wrong host or port, a closed port, a TLS server reached over `redis://`, bad credentials), the process exits with `Redis at redis://host:6379/0 did not answer the startup ping within 3000 ms (...)`, the URL printed without its credentials; fix `REDIS_URL` or unset it to run on the in-process cache. Once started, a Redis that goes away does not stall requests: the client keeps no offline queue, so a cache read or write fails at once (logged as `redis cache error`) and the page is rendered as a cache miss until the server is back, when the client reconnects on its own. - **Meilisearch** (`SEARCH_URL`, `SEARCH_API_KEY`). Every publish sends the entity's document (title, body text, term labels, locale, type, status) to the index `spillway_`; queries get typo tolerance, highlights and facet counts by type and term (`facets` in `GET /api/search`). Index writes are queued so a slow or absent server never delays a publish (failures are logged); run `spillway search reindex` after enabling it or after an outage. The SQL index stays in sync as well, so turning Meilisearch off again loses nothing. Both are optional for the Docker Compose file: `docker compose --profile redis --profile search up -d` starts them. ### The screenshot renderer Migrate a site compares every migrated page with the original ([importer.md, Migrate a site](importer.md#review-the-score-and-the-visual-comparison)). The words, the structure and the header, navigation and footer are compared by the server itself; the visual comparison needs a browser, which Spillway's image does not carry. The renderer is a small service with Playwright and Chromium (`scripts/renderer.mjs`) that draws a page's HTML at a width and answers with a PNG and where the header and footer sit; Spillway compares the two pictures at desktop (1,280 pixels) and phone (390 pixels) widths and keeps the screenshots with the migration until it is deleted. - **Docker Compose**: `docker compose --profile renderer up -d` and `SPILLWAY_RENDERER_URL=http://renderer:3200` for the `spillway` service. To require a token, set the same `SPILLWAY_RENDERER_TOKEN` for both (the compose file passes it to the renderer as `RENDERER_TOKEN`). - **Elsewhere**: `node scripts/renderer.mjs` on a machine with Playwright and Chromium (`PORT`, default 3200), and point `SPILLWAY_RENDERER_URL` at it. - **Hosted sites**: the platform runs it. Import from Storybook ([getting started](getting-started.md#site-components)) uses the same renderer: it draws each picked component's main story, framed from the Storybook's `iframe.html`, so the AI drafting the component sees it. Without a renderer, the AI works from the story's name, args and description. The renderer loads the old site's stylesheets and images from the old site and the new page's from Spillway (the one private host it is told it may reach). The browser fetches nothing itself: the renderer makes every request a page asks for (stylesheets, images, scripts, frames, `fetch`) under the same rules as Spillway's outbound requests ([security.md, Outbound requests](security.md#outbound-requests-ssrf-policy)): host names are resolved and refused when any answer is private, every spelling of an address counts as what it is (`[::ffff:169.254.169.254]` is the metadata address), the connection goes to the address that was checked, and each redirect is checked again. WebSockets, service workers and WebRTC's direct UDP are off. It refuses every private or local address but Spillway's unless it runs with `RENDERER_ALLOW_PRIVATE=1` (an intranet site, the smoke tests). Give its container no other route into your network all the same. It publishes no port in the compose file and keeps nothing. ### Reverse proxy Put Spillway behind a TLS-terminating proxy in production and set `BASE_URL` to the public `https://` origin (that also turns on `Strict-Transport-Security`). With `TRUSTED_PROXIES` set (below), `X-Forwarded-Proto: https` from the proxy is honored too, so the `Secure` and `__Host-` cookie flags and HSTS follow the real scheme even when `BASE_URL` is unset or several hostnames serve the site; from an untrusted peer the header is ignored. Spillway uses the visitor's address for login and form rate limiting and for the derivative cache, and it only believes `X-Forwarded-For` when the request came from a proxy you named in `TRUSTED_PROXIES`; otherwise every visitor behind the proxy would share one bucket, and a visitor could forge the header. Set it to the proxy's address or range: - Caddy or nginx on the same machine: `TRUSTED_PROXIES=loopback` (`127.0.0.0/8, ::1/128`). - Docker behind Caddy, nginx or Traefik on the Docker network: `TRUSTED_PROXIES=172.16.0.0/12` (Docker's default bridge and compose networks), or the exact subnet from `docker network inspect`; `private` covers every RFC 1918 range when you do not want to look it up. - Fly.io: `TRUSTED_PROXIES=fly`; Fly's edge sets `Fly-Client-IP`, which is then used. A request from another app on the organization's private network (`fdaa::/16`) does not pass through the edge, so its own address is used and its headers are ignored; if one of your apps is a proxy in front of Spillway, add its private addresses (`fly, fdaa:0:1:a7b::/64`). - Fly.io behind Cloudflare (the record proxied, orange cloud): `TRUSTED_PROXIES=fly, cloudflare`. Fly's `Fly-Client-IP` is then a Cloudflare address, and Spillway takes the visitor's from `CF-Connecting-IP` and the scheme from `CF-Visitor`, but only when the address Fly saw is in Cloudflare's ranges: a request that reaches Fly directly (a custom domain not behind Cloudflare, or the app's `fly.dev` name) keeps `Fly-Client-IP`, whatever `CF-Connecting-IP` it sends. Cloudflare alone in front of the server: `TRUSTED_PROXIES=cloudflare`; behind your own proxy behind Cloudflare: `loopback, cloudflare`. The ranges are bundled with the release; `CLOUDFLARE_IPS` replaces them. Anything that runs on Cloudflare, a Worker included, connects from those ranges, so treat the address as good for rate limits, not as proof of who is asking. - Kubernetes, Render, Railway: the ingress or platform proxy's pod/network range, or `*` when the port is reachable only through that proxy. Spillway keeps idle keep-alive connections open for 65 seconds, longer than the 60 second idle timeout most proxies and load balancers use, so the proxy never reuses a connection the server is closing at the same moment. Responses are gzip-compressed when the client sends `Accept-Encoding: gzip` (HTML, JSON, XML, text and scripts from 1 KB up; images are left alone), and every public page carries a weak `ETag`; a proxy that compresses on its own can send `Accept-Encoding: identity` to the origin. With a trusted peer, the client is the rightmost `X-Forwarded-For` hop that is not itself a trusted proxy, so a hop the client added itself is ignored. Caddy (`Caddyfile`), with automatic HTTPS: ``` www.example.org { reverse_proxy localhost:3000 } ``` nginx: ```nginx server { listen 443 ssl http2; server_name www.example.org; ssl_certificate /etc/letsencrypt/live/www.example.org/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/www.example.org/privkey.pem; client_max_body_size 65m; # media uploads are capped at 25 MB, module archives at 64 MB; Spillway enforces both itself location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } ``` Spillway serves pages with `Cache-Control` and `Cache-Tag` headers, so a CDN or cache in front of the proxy can store published pages and purge by tag. See [architecture.md](architecture.md). ### Fly.io The quickest way is [`deploy/fly/launch.sh`](../deploy/fly/README.md), with `flyctl` installed and logged in: ```bash deploy/fly/launch.sh my-site --region ams ``` It creates the app, a volume for `/data`, a session secret and a setup token, deploys the released image with [`deploy/fly/fly.toml`](../deploy/fly/fly.toml), waits for `/healthz` and prints the setup wizard's address with the token. Running it again keeps what exists. By hand, the same steps are: ```bash fly launch --no-deploy # answer the prompts; pick a region fly volumes create spillway_data --size 1 fly secrets set SESSION_SECRET="$(openssl rand -base64 48)" fly deploy ``` `fly.toml`: ```toml app = "my-spillway" primary_region = "ams" [build] image = "ghcr.io/kwall-llc/spillway-cms" [env] PORT = "3000" DATA_DIR = "/data" BASE_URL = "https://my-spillway.fly.dev" [[mounts]] source = "spillway_data" destination = "/data" [http_service] internal_port = 3000 force_https = true auto_stop_machines = "stop" auto_start_machines = true min_machines_running = 1 [[http_service.checks]] interval = "30s" timeout = "5s" method = "GET" path = "/healthz" ``` Keep one machine with SQLite: it lives on the volume and the page cache is in-process. Set `min_machines_running = 1` so the first request after idle is not slow. With [Fly Postgres](#fly-postgres) you can scale out. To update Spillway from **Admin → Updates** instead of with `fly deploy`, add a deploy token as `SPILLWAY_FLY_API_TOKEN` ([One-click updates](#one-click-updates)). ### One-click deploys The README has **Deploy to Render** and **Deploy on Railway** buttons. Both run the released image (`ghcr.io/kwall-llc/spillway-cms:latest`) as one service with a persistent disk at `/data`, a health check on `/healthz` and a generated `SETUP_TOKEN`: - **Render** reads [`render.yaml`](../render.yaml) from the repository root: a starter web service (disks need a paid instance) with a 1 GB disk. After the deploy, open the service's **Environment** tab, copy `SETUP_TOKEN`, and open the service's URL to run the setup wizard with it. - **Railway** uses a template built from [`deploy/railway`](../deploy/railway) (its README lists how the template is set up). Copy `SETUP_TOKEN` from the service's **Variables** and open the generated domain. On Render, add the service's deploy hook as `SPILLWAY_DEPLOY_HOOK_URL` to update Spillway from **Admin → Updates** ([One-click updates](#one-click-updates)). Until you set `BASE_URL`, the server takes its public address from the platform: `RENDER_EXTERNAL_URL` on Render, `https://$RAILWAY_PUBLIC_DOMAIN` on Railway and `https://$FLY_APP_NAME.fly.dev` on Fly. Set `BASE_URL` (or give the site a domain in the admin) when you add a custom domain. Platforms without persistent disks (Heroku, DigitalOcean App Platform) are not offered: uploads and SQLite need `/data` to survive a restart. ### Railway, Render, Coolify All three can run the image directly. Give it a persistent disk mounted at `/data`, expose port 3000 and set `BASE_URL`. - Railway: `railway init && railway up` with a `Dockerfile` that is just `FROM ghcr.io/kwall-llc/spillway-cms`, then add a volume mounted at `/data` in the service settings and set `BASE_URL` to the generated domain. - Render: create a Web Service from the image `ghcr.io/kwall-llc/spillway-cms`, add a disk at `/data`, health check path `/healthz`, env `BASE_URL`. Disks require a paid instance. - Coolify: New resource, Docker Image, `ghcr.io/kwall-llc/spillway-cms`, port 3000, a persistent storage at `/data`, env `BASE_URL`. ### Mail Form email connectors and notification rules send through one mail relay per instance. Set it in the admin: **Site settings → Mail** (admins), pick the provider, paste its key, set the From address, **Save**, then **Send test email**. Postmark, Resend, SendGrid, Mailgun and Amazon SES are presets (the host, port, TLS mode and fixed user name are filled in); **Other SMTP server** takes any relay. The key is stored encrypted with the instance key (`DATA_DIR/ai-secret`, which backups carry) and is never shown again. A relay set in the admin must be a public host: like webhook URLs, a host that is internal or resolves to a private address is refused unless the server runs with `SPILLWAY_ALLOW_PRIVATE_URLS=1`, and the unencrypted mode (**None**, for a relay on the same network) needs that setting too. `SMTP_URL` in the environment is the operator's choice and is not checked. `SMTP_URL` in the environment takes precedence: when it is set, the Mail tab says mail is set by the server and cannot be changed there, shows its server and From address read-only, and saving there is refused (409 `mail_env`, which says to ask whoever runs the server, or the host when `SMTP_DEFAULT_URL` is set too), so an instance configured by environment keeps working unchanged. Unset it to manage mail in the admin. With neither, messages are written to the log instead of sent. `SMTP_DEFAULT_URL` (with `SMTP_DEFAULT_FROM`) is for hosts that run sites for others, such as a hosting platform: it is the relay a site uses until its admin sets their own under **Site settings → Mail**, which then replaces it. Unlike `SMTP_URL` it does not lock the Mail tab, which shows it as **Your host's relay** (server and From only, never the credentials); removing the admin's own settings goes back to it. `SMTP_URL` still wins over both. On a copy with `SPILLWAY_OUTBOUND=off` no mail is sent at all, whatever relay is set: account email, form email, notifications, agent results and module mail are written to the log (and audited as `outbound.suppressed`) instead, and **Send test email** is refused. See [Copies of a site](#copies-of-a-site). The relay also sends account email: invites from **Users → Invite a user**, password reset links, and the answer to **Forgot your password?** on the sign-in screen. Without a relay, the admin who invites someone or sends a reset copies the link from the screen instead, and **Forgot your password?** tells people to ask an administrator. Links in these emails use `BASE_URL` (or a domain an admin gave the site), so set it before relying on password resets. Before the first real message, verify the From domain with the provider and publish the DNS records it gives you, usually: - an SPF record (a TXT record on the domain starting `v=spf1`; one per domain, so merge it with an existing one); - DKIM (one or two records the provider names); - one DMARC record, a TXT record at `_dmarc.` such as `v=DMARC1; p=none; rua=mailto:you@example.org`. A domain with two DMARC records has none as far as mail providers are concerned. **System → Go live** checks the From domain's SPF, DMARC and MX records and whether the last test email went through. #### Hosted sites A hosting platform that runs Spillway sites for others sets `HOST_API_URL` and `HOST_API_KEY` on each site. The site then: - runs AI through the host when a provider has no key of the site's own: Anthropic's Messages API at `/ai/anthropic`, with `HOST_API_KEY` as the key. The host pays the provider and charges the site's AI credits; when they run out it answers 402 and AI tasks fail with `ai_credits_exhausted` until the next month or a credit pack. A key added under **Site settings → AI** replaces the host for that provider and is never charged. AI starts switched on. - shows **Site settings → Usage and plan** (`GET /api/hosting/usage`, which reads `GET /usage` with the key): the plan, the billing period and a chart per meter (bandwidth, storage, AI credits) with the usage so far, the allowance and where the period ends at the current pace, with a link to change the plan or buy credits. - shows the **Hosting** card on the dashboard and under **Usage and plan** (`GET /api/hosting/summary`, which reads `GET /summary` with the key and keeps the answer a minute): up or down with the 30-day uptime, the latest backup and the next, the version and the update window, with links to manage them on the host. The host answers only; nothing on the site can restore or change hosting through the key. - offers **Buy AI credits** and **Upgrade plan**, or **Ask for more credits** and **Ask to upgrade**, where usage and AI credits show (`GET /api/hosting/upgrade`, which posts the signed-in person, their host user id when they came through Open admin, their email and name, to `/upgrade/options` and keeps the answer a minute; `POST /api/hosting/upgrade/request`, which forwards to `/upgrade/requests`). The host decides who may pay. The key never spends: Buy and Upgrade link to the host's own page, where the person signs in and confirms, so a site whose key leaks, or an administrator who does not pay, cannot charge the account; a request only emails the account's payers, within the host's limits. See [Usage and plan](getting-started.md#usage-and-plan). - lets the host decide who opens the admin. **Open admin** on the host sends the person to `/hosting/sign-in?token=...` with a one-time token; the site redeems it at `POST /sign-in` and the host answers who it is and their roles at that moment (an organization's Owners and Admins as Administrators, others with the roles their access gives), and `twoStep`, whether the person used two-step sign-in in the host's sign-in that made the link. Where the site requires two-step sign-in of the person (Site settings → Security), a link without `twoStep: true` is refused and the person is asked to turn two-step on for their hosting account. The site keeps a user per person (signing in through the host, shown as `spillway-hosting`), so the audit log names them; a local account with the same email, such as the first administrator, is linked and keeps its password. Roles the site does not have are dropped. Once an hour the site reads `GET /access`: roles follow the host, and people whose access ended are deactivated and signed out until the host gives it back. Spillway hosting on spillwaycms.com sets both on every site it provisions. With its sign-in service, it also sets the three variables below. ##### Hosted sign-in Google and Microsoft send people back only to callback addresses registered with them in advance, and a hosted site's address is not known when an app is registered. So a hosting platform can register one Google app and one Microsoft app whose callbacks are on a host of its own, and pass each result on to the site that asked. A site uses it when the platform sets `HOST_SIGNIN_URL`, `HOST_SITE_ID` and `HOST_SIGNIN_PROVIDERS` next to `HOST_API_KEY`, and `BASE_URL` is set: - **Site settings → Accounts** offers **Google (Spillway hosting)** and **Microsoft (Spillway hosting)** for the providers the platform names, when the instance has no Google or Microsoft provider of its own under **Site settings → Sign-in** (its own wins). The toggles start off. - **Starting.** `GET /account/google` (or `/account/microsoft`, or **Connect** on the account page) keeps the flow in the site's signed cookie, as for the site's own provider, and redirects to `/start` with the site's id, the provider, the site's callback (`/account//callback`), the flow's `state`, the time and a signature. The signature is an HMAC-SHA256 keyed by the SHA-256 of `HOST_API_KEY` (the platform keeps only that hash of the key) over those values, so the platform knows the request is the site's and sends the person back only to the site's own address. The key never leaves the server. - **Finishing.** The platform's service sends the browser back to the callback with `assertion` and `state`. The assertion is a JWT the service signs with an ES256 key; the site checks it against the key set at `/.well-known/jwks.json` (kept ten minutes; an unknown key id refetches it, at most every 30 seconds): issued by `HOST_SIGNIN_URL`, for `HOST_SITE_ID`, at most two minutes old and two minutes long, for this provider and this flow's state, and used once (its `jti` is kept in `account_assertion` until it would have expired). The callback answers with `Referrer-Policy: no-referrer` and redirects at once. Then the sign-in goes on exactly as with the site's own app, through the site's registration check ([Site settings → Accounts](getting-started.md#accounts)): identities are linked by Google's `sub` or Microsoft's tenant and object ids, a first sign-in joins or creates an account only by an address the provider verified, and two-step sign-in is asked after. - **When the service is down.** The pages that show the buttons (log in, sign up, an invitation, Connected sign-ins) read `/status` (giving up after three seconds, keeping the answer for a minute) and leave out a button the service is not offering or when it does not answer. Password sign-in, the reset link and the site's own providers keep working, and members' accounts are the site's. - **Never the admin.** The admin's sign-in and **Open admin** are unchanged; assertions only reach the public account pages. Spillway hosting sets these on its sites once its sign-in service offers a provider. The security notes are in [security.md](security.md#site-accounts-connected-sign-ins). ### Copies of a site A copy of a production site (a staging copy, a preview, a restored copy someone is inspecting) holds production's form connectors, notification rules, relay, CDN settings, provider keys and tracking ids. Start it with `SPILLWAY_OUTBOUND=off` so it does not act on them. The admin and the public pages keep working, and so do sign-in, publishing, scheduled publishing and the ticker; what would reach the outside world is held back: | What | On a copy with `SPILLWAY_OUTBOUND=off` | | --- | --- | | Form submissions | Stored as usual. Their connectors (webhook, HubSpot, email) do not run: each is recorded on the submission as **Not sent**, and the status stays **Received**. Modules' `form.afterSubmit` handlers do not run. | | Payments | A payment form's submission is stored as **Unpaid** and no Stripe Checkout is created; the visitor is told no payment was taken (409 `outbound_off`). | | Mail | Nothing is sent, whatever `SMTP_URL`, the Mail tab or `SMTP_DEFAULT_URL` says: invites, password resets, form and notification email, agent results and module mail are written to the log, and invitation links are shown in the admin as when no relay is set. **Send test email** is refused. | | Notifications | Rules queue as usual; the outbox marks each row **Not sent** (`suppressed`) instead of delivering it, and never retries it. Content webhooks are notification rules, so they are held back too. | | Modules | `api.http` (trusted) and `sw_http` (sandboxed) answer 409 `outbound_off` before anything leaves, `api.mail.send` answers `not_configured`, and each refusal is in the module's log. | | AI | The keys saved under **Site settings → AI** (and provider keys in the environment) are never used. With `HOST_API_URL` and `HOST_API_KEY` set, every task runs through the host's AI proxy, which meters the copy under the host's key and may refuse it; without them AI answers 409 `outbound_off`. | | CDN | Purges are queued and recorded as **skipped** in **Site settings → Cache**, never sent, so the CDN in front of production is left alone; the connection test is refused. | | Tracking | Google Tag Manager, Google Analytics, Plausible, the tracking tags, the scripts in the custom head markup and the footer code are left out of public pages (meta and link tags stay). The settings themselves are kept. | | Translations | A job for a TMS provider is kept as failed and not sent; cancelling does not tell the provider. Downloading a bundle by hand works. | | Backups | Scheduled backups to an `s3://` `BACKUP_TARGET` are skipped and **Run now** is refused, so a copy never writes into production's bucket; a directory target works. | | Media on object storage | With `MEDIA_STORAGE`, the bucket is read only: the copy shows production's files, keeps new uploads on its own disk (and never drops them from the cache), and a delete removes the file from its disk only. Nothing is uploaded to or deleted from the bucket. | Reading from the outside world is not affected: sign-in (SSO, Google and Microsoft, the host's **Open admin** and access sync), registry and kit downloads, update checks, the importer, CAPTCHA checks, Google Fonts and free media libraries. A trusted module runs in the server process: its `api.http` and `api.mail` are held back, but a module that opens connections of its own is not, so leave such modules disabled on a copy or use sandboxed ones. The admin shows **Outbound actions are off on this copy** at the top of every screen, and the Mail, Notifications, Cache, AI, Integrations, Forms and Modules screens say what they do not send. `GET /healthz` answers `"outbound":"off"` (and `"on"` on a normal site), and `GET /api/auth/me` carries `outbound: 'off'` for signed-in users. Every held-back action writes an `outbound.suppressed` audit row with its `kind` (`form.connectors`, `form.modules`, `form.payment`, `mail`, `notification`, `module.http`, `module.mail`, `ai`, `cdn.purge`, `translation`, `backup`) and what would have gone where (recipients, hosts, connector kinds; never a message body or a secret). A copy usually also wants `SITE_LOCK_PASSWORD`, so visitors and search engines do not find it, and a `BASE_URL` of its own. With outbound actions off, an unroutable `SMTP_URL` and `SPILLWAY_TICKER=0` are no longer needed to keep it quiet: the ticker can run, so scheduled content publishes on the copy as it would in production. ### Media on object storage By default the media library's files are on the disk, under `/media`. With `MEDIA_STORAGE` they live in an S3-compatible bucket and the disk keeps a cache of them, so the library can outgrow the disk and does not depend on it: ```bash MEDIA_STORAGE=s3://my-media/spillway/www # each file at // MEDIA_S3_ENDPOINT=https://.r2.cloudflarestorage.com # R2; Tigris: https://fly.storage.tigris.dev; AWS: unset MEDIA_S3_ACCESS_KEY_ID=... MEDIA_S3_SECRET_ACCESS_KEY=... MEDIA_CACHE_MB=2048 # optional: how much of the disk the cache may fill ``` - **Addresses do not change.** Files are still served by the server at `/media//`, with the same headers (a year's `immutable` cache for public files, `private, no-store` for members-only ones), so a CDN in front of the site caches them as before and the bucket stays private. A file the cache lacks is fetched from the bucket on first use. - **Uploads** go to the disk and the bucket before the upload is answered; a failed bucket write fails the upload. **Delete** and **Replace file** remove the old objects. - **Video ranges** (`Range: bytes=...`, how players fetch video) of a file the cache lacks are read from the bucket with a ranged GET and streamed to the visitor, so a video starts without waiting for the whole file; the cache fetches the file in the background for the next request. The answers carry the same ETag as from the disk. - **Image sizes** (`?w=`, `?fmt=`) are made from the original on the disk and kept on the disk only; they are made again after the cache dropped them. - **The cache** keeps to `MEDIA_CACHE_MB`. Past it, the least recently used files are dropped until it is at 80%, image sizes before originals. An original is dropped only once the bucket holds it at the same size; one the bucket lacks is uploaded first. - **Files written straight to the disk** (a restore without `MEDIA_STORAGE`, an import, a file copied in by hand) are uploaded by the server in the background: at the first tick after a start and every six hours (`SPILLWAY_TICKER`), and before the cache drops them. - **Deletes** remove the objects at once, or with `MEDIA_DELETE_AFTER_DAYS` that many days later: each delete is written to a journal in the bucket (`/_deleted//...`), and once a day the server removes the objects of journals older than that whose files no media item names. A database restored from a snapshot of its own (not from a backup run, which carries the media) therefore still finds the files it names. - **Credentials** need read, write, list and delete on the prefix. The server stops at start without them. **Moving an existing site.** Copy the files first, switch, then copy again what was uploaded in between: ```bash pnpm spillway media migrate --to s3://my-media/spillway/www --dry-run # what it would upload (MEDIA_S3_* set) pnpm spillway media migrate --to s3://my-media/spillway/www # copies what the bucket lacks; safe to run again ## set MEDIA_STORAGE=s3://my-media/spillway/www and restart, then: pnpm spillway media migrate # catches uploads made during the switch ``` The files stay on the disk as the cache, and the cache limit trims them over time. Nothing is deleted from the disk by the migration. To move back, run `spillway media fetch` (it downloads every file the disk lacks), unset `MEDIA_STORAGE` and restart. **Exports and backups.** `spillway export` writes the media metadata only; a tool that packs `DATA_DIR/media` should run `spillway media fetch` first, since the disk holds only the cache. Backup runs read each file from the cache or the bucket and copy new ones to the backup target as before; a file already in the previous run is not downloaded again (its hash comes from that run's `media.json`). `spillway restore --media` puts the media files the bucket lacks back into the bucket. ### Backups With SQLite, everything is under `DATA_DIR`: ``` data/ spillway.db SQLite database (plus spillway.db-wal and spillway.db-shm while running) media// uploaded files and their cached derivatives (_v/) session-secret generated session key (mode 0600) sso-secret key for the stored SSO client secrets (sso.md; mode 0600) ai-secret key for the stored AI, DAM, TMS and CDN credentials (mode 0600) form-uploads/ files visitors attached to forms imports/ raw pages fetched by the domain importer modules// installed modules registry/ published tarballs, on a registry host (REGISTRY_STORAGE) restart-stamp when a module change last restarted the server backups/ what `spillway backup` (without --to) writes restore/ a restore from the admin: the staged run, the pre-restore copy and its journal ``` #### What a backup contains A backup run (`spillway backup --to`, the schedule or **Run now**) carries everything a restored instance needs to behave like the one that was backed up: | In `DATA_DIR` | In the backup | Why | | --- | --- | --- | | `spillway.db` | yes, as a consistent, compact dump (SQLite's `VACUUM INTO`, which leaves free pages out, or `pg_dump` on Postgres) | the content, users, settings, sessions, module state | | `session-secret`, `sso-secret`, `ai-secret` | yes, in `keys.json` | the **key files**: without them every stored SSO client secret and AI, DAM, TMS and CDN credential is unreadable after a restore, and every session ends | | the `REGISTRY_SIGNING_KEY` PEM | yes, when it lies inside `DATA_DIR` | a registry host keeps signing its index with the same key | | `modules/` | yes, every file (`modules.json`) | installed modules load again; whether each is enabled and its settings are in the database | | `media/` | yes, unless `--no-media` (`media.json`) | the media library; cached derivatives are rebuilt on demand | | `form-uploads/` | yes, unless `--no-media` (`form-uploads.json`) | form submission attachments download again | | `registry/` | yes on a registry host, unless `--no-media` (`registry.json`) | published tarballs; a `REGISTRY_STORAGE` outside `DATA_DIR` is yours to back up | | `imports/` | no | the importer's scratch copies of fetched pages and assets; what was imported is in the database and the media library | | `restart-stamp`, `backups/`, `restore/` | no | a rate limit for module restarts, local copies from `spillway backup --out`, and a restore's staging and pre-restore copies | Secrets the instance reads from its environment are not in `DATA_DIR` and so not in a backup: keep `SESSION_SECRET` (when you set one), `SMTP_URL`, provider keys you set as variables, the `BACKUP_S3_*` credentials and `BACKUP_ENCRYPTION_KEY` itself in your secret store. The manifest notes when `SESSION_SECRET` came from the environment, and the restore reminds you to set it. **Set `BACKUP_ENCRYPTION_KEY`.** Because the key files are inside every backup, anyone who can read the backup target can decrypt the stored credentials. With the key set, every member of a run is encrypted with AES-256-GCM (only media files stay in clear, as they are public once published). Without it the key files are still included, since a backup that cannot be restored is worse, but the run is marked with the `unencrypted_secrets` warning, the **Backups** card under Site settings → **System** shows how to fix it, `/status.json` reports `backup_unencrypted`, and the server logs a warning at boot when the target is `s3://`. Keep the key outside the instance (a password manager, your platform's secret store): it is the one thing a backup cannot carry. #### Scheduled backups to object storage Set a target and a schedule, and the server backs itself up: ```bash BACKUP_TARGET=s3://my-backups/spillway/www # or a directory: /mnt/backups/spillway BACKUP_SCHEDULE=daily@03 # hourly, daily[@HH[:MM]], weekly[@HH | @DAY [HH[:MM]]], in UTC BACKUP_RETENTION_DAYS=30 # 0 keeps every run BACKUP_MONTHLY_RETENTION_DAYS=365 # optional: each month's first scheduled run kept a year BACKUP_ENCRYPTION_KEY=$(openssl rand -hex 32) # recommended (backups carry the key files); keep a copy outside the instance BACKUP_S3_ENDPOINT=https://.r2.cloudflarestorage.com # R2; Tigris: https://fly.storage.tigris.dev; AWS: unset BACKUP_S3_ACCESS_KEY_ID=... BACKUP_S3_SECRET_ACCESS_KEY=... ``` Each run is a folder named by its UTC time under the target, plus shared folders of files stored once by content hash: ``` s3://my-backups/spillway/www/ 20261106-030000/spillway.db the database (spillway.db.enc when encrypted; spillway.pgdump on Postgres) 20261106-030000/keys.json the key files (keys.json.enc when encrypted) 20261106-030000/modules.json every file of every installed module: path, size, mode and sha256 (.enc when encrypted) 20261106-030000/form-uploads.json every form upload, the same way (.enc when encrypted) 20261106-030000/registry.json a registry host's tarballs, the same way (.enc when encrypted) 20261106-030000/blobs.json the shared files this run names (content hashes only), for pruning 20261106-030000/media.json every media item: id, file name, type, size and sha256, or its DAM reference 20261106-030000/backup.json written last: version, applied migrations, a checksum of every member, encryption, warnings media/ each media file once, by content hash modules/[..enc] each module file once (form-uploads/ and registry/ likewise); encrypted ones carry the key's id ``` Backups are incremental for media, form uploads, modules and registry tarballs: a run uploads only the files whose content hash the target does not hold yet (with a key set, encrypted files are named by the key's id too, so changing the key uploads them again), and items that live in a DAM are referenced, not copied. A run without `backup.json` is incomplete and is never restored. The ticker starts a run once per slot (and once at the first tick of a fresh instance, so a backup exists before the first slot), one at a time, in the background; it records every run in the database and, at most once a day (`prune.json` at the target's root says when it last did), deletes runs older than `BACKUP_RETENTION_DAYS` (always keeping the newest, and with `BACKUP_MONTHLY_RETENTION_DAYS` each month's first scheduled run until that many days have passed) and the shared files no remaining run names. A month whose first scheduled run failed keeps its next scheduled run that finished; a run made by hand is kept as the month's only when no scheduled run finished that month. Once a day keeps pruning cheap for an hourly schedule kept for a long time: each pruning reads every remaining run's manifests, eight at a time. A failed run sends the **Backup failed** notification to any rule for it (Site settings → Notifications). A run belongs to the process that makes it: when the server starts, the runs its own machine left running (the server or `spillway backup` stopped mid-run: a crash, a restart, a deploy) are marked failed at once, with "The server stopped while this backup ran". A run whose process is still alive on this machine is left alone, and a run another machine on the same Postgres database left running (or one recorded before Spillway kept track of the machine) is marked failed once it has been running for six hours. Site settings → **System** lists the runs and has a **Run now** button (`POST /api/system/backups/run`, see [api.md, System](api.md#system)). With `SPILLWAY_TICKER=0`, run `spillway backup` from cron instead. The S3 client is built in (SigV4 on `node:crypto`, path-style requests, no SDK) and goes through the same outbound guard as webhooks, so an endpoint on a private network needs `SPILLWAY_ALLOW_PRIVATE_URLS=1` (a MinIO next to the server). The credentials need read, write, list and delete on the prefix. A run streams from file to file, so its memory use does not grow with the database: the dump is written to the system's temporary folder, encrypted from there into a second file a chunk at a time (the plain dump is deleted once the encrypted copy exists), and uploaded from that file. On S3 a file larger than 16 MB goes up as a multipart upload in 16 MB parts (any part that fails aborts the upload, so the bucket keeps no stray parts); media files, form uploads and module files are uploaded from the disk the same way. The temporary folder needs free space of about twice the database. A restore streams the other way: each download goes to a file next to its destination, is checked and decrypted from there, and is moved into place only after every check passes. From the terminal: ```bash pnpm spillway backup --to s3://my-backups/spillway/www # one run now (BACKUP_TARGET is the default) pnpm spillway backup --to /mnt/backups/spillway --no-media # without media, form uploads and registry tarballs (key files and modules stay in) ``` #### Restoring `spillway restore` takes a run folder, or a target to restore its newest run. Stop the server first: the restore replaces the database file directly. Without server access, use [Restore in the admin](#restoring-from-the-admin) instead. ```bash pnpm spillway restore s3://my-backups/spillway/www --dry-run # newest run: download, verify, report what would change pnpm spillway restore s3://my-backups/spillway/www/20261106-030000 --media pnpm spillway restore /mnt/backups/spillway --data-dir /srv/spillway-copy --media # into another data directory ``` It downloads the run, checks every member against the checksums in `backup.json` (before and after decrypting with `BACKUP_ENCRYPTION_KEY`) before it writes anything, refuses a backup taken by a newer Spillway (upgrade first), refuses a destination database that was migrated further than the backup unless you pass `--force`, verifies the SQLite file with `quick_check`, and keeps the replaced database next to the new one as `spillway.db.before-restore-`. The list of backup runs is carried over from the replaced database, as a restore from the admin does, so the run restored and the runs after it show how they ended rather than **Running** (every run reads running in its own copy of the database); restored into a fresh directory, the run restored shows **OK**. It then puts the key files back with mode `0600` and the installed modules back under `modules/` (their enabled state and settings came back with the database), and with `--media` writes every media file, form upload and registry tarball whose content differs from what is on disk (with `MEDIA_STORAGE`, each media file the bucket lacks goes back into the bucket instead). Start the server afterwards: stored credentials decrypt, existing sessions stay signed in, form uploads download and modules load. The server applies any migrations newer than the backup. `--dry-run` does every download and check, lists every file it would write (the database, each key file, each module file, each media file and form upload) and writes nothing. Key files are never replaced silently. If the data directory already holds a key file that differs from the backup's (an instance that was started once before the restore generates its own), the restore stops before writing anything and names the files: keeping them would leave the backup's credentials unreadable, and replacing them does the same to anything saved with the current keys. Pass `--force` to replace them; the current files are kept as `.before-restore-`. Restore into a fresh directory, or one whose instance you are replacing, and start the server only after the restore. A Postgres run restores the key files, modules and files the same way; the database itself goes back with the printed `pg_restore` command. #### Restoring from the admin People without server access restore from **Site settings → System → Backups**: every finished run on `BACKUP_TARGET` has **Restore**, for administrators (the `system.restore` permission). The dialog lists what the run replaces, per its `backup.json` (the database, the key files, modules, and with media the media library, form uploads and registry tarballs; what the run does not hold is kept), says that everything after the run's time is lost, and asks for the site's name or address. Restoring needs the server not serving the database it replaces, so it happens in two phases: 1. **Staging, while the site keeps serving.** The server first backs itself up as it is (a run with the trigger `pre_restore`, listed as **Before a restore**; if it fails, the restore stops and says why), then downloads the chosen run into `DATA_DIR/restore/staging-/`: every member checked against `backup.json` before and after decrypting with `BACKUP_ENCRYPTION_KEY`, a backup from a newer Spillway refused, the database checked with `PRAGMA quick_check`. Media and form uploads whose content the instance already holds are linked from the current folders instead of downloaded (modules and registry tarballs are copied), so staging yesterday's run downloads little. It refuses to start when the disk under `DATA_DIR` lacks room for what it downloads plus the database, while another backup or restore runs, and on Postgres. Progress shows on the run's row. 2. **The swap, on the next start.** Staged, the server writes `DATA_DIR/restore/pending.json` and restarts (exit code 75, as after a module change). On the next start, before it opens the database, it moves the current database (with its `-wal` and `-shm`), key files, `modules/`, `media/`, `form-uploads/` and `registry/` to `DATA_DIR/restore/pre-restore-