Files
dckcandClaude Opus 5.5 857816166e feat(diigo-cache): production deployment with tailscale, systemd, and nix
diigo binds the session cookie to the IP it was issued to, so a
Cloudflare deployment can't use a cookie minted in the browser. Run
diigo-cache and webapp in one workerd on bldbox instead.

The flake bundles each worker with wrangler's dry run, so the modules
match what `wrangler deploy` ships, and generates the workerd config
from the bundles. workerd comes from nixpkgs' wrangler, the only
packaged one. A smoke check serves the home page and mints a webapp
instance, which covers the WEBAPP binding and Durable Object storage.

The service is a system unit with DynamicUser, so the webapp state
holding the cookie isn't readable by processes running as the user.
It listens on loopback behind tailscale serve: HTTPS, which
PasswordCredential needs, at the tailnet name only.

Operator docs in doc/; unsettled points recorded as IBIS issues.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-14 23:12:47 -05:00

42 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Fill config.capnp.in from `wrangler deploy --dry-run` outdirs.
# usage: gen-config.sh <dist> <template> <cache-date> <webapp-date> > config.capnp
# <dist>/cache and <dist>/webapp each hold index.js plus the text modules
# wrangler.jsonc's rules name (*.sql, capnweb's browser build); embed
# paths are relative to the config, which sits beside them.
set -euo pipefail
dist=$1 template=$2 cache_date=$3 webapp_date=$4
modules() {
local dir=$1
if [[ ! -f $dist/$dir/index.js ]]; then
echo "gen-config: $dist/$dir/index.js: missing" >&2
exit 1
fi
echo " (name = \"index.js\", esModule = embed \"$dir/index.js\"),"
for f in "$dist/$dir"/*; do
local name=${f##*/}
case $name in
index.js | README.md | *.map) ;;
*.sql | *-index.js) echo " (name = \"$name\", text = embed \"$dir/$name\")," ;;
*)
echo "gen-config: $dir/$name: no module type rule" >&2
exit 1
;;
esac
done
}
cache_modules=$(modules cache)
webapp_modules=$(modules webapp)
while IFS= read -r line; do
case $line in
@CACHE_MODULES@) echo "$cache_modules" ;;
@WEBAPP_MODULES@) echo "$webapp_modules" ;;
*)
line=${line//@CACHE_DATE@/$cache_date}
echo "${line//@WEBAPP_DATE@/$webapp_date}"
;;
esac
done <"$template"