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>
This commit is contained in:
1 parent
9c3eaa9819
commit
857816166e
14 files changed
+580
-2
No files matched your search
@@ -0,0 +1,60 @@
|
||||
# diigo-cache and the webapp it reads diigo through, in one workerd.
|
||||
#
|
||||
# The listening socket has no address here: systemd hands it in
|
||||
# (-S http=3), so holding the socket is the authority to reach the cache.
|
||||
# State directories likewise come from the command line:
|
||||
# -d cache-state=<dir> -d webapp-state=<dir>.
|
||||
#
|
||||
# Durable Object unique keys follow miniflare's `<script>-<class>`, so a
|
||||
# `wrangler dev` state directory names its objects the same way.
|
||||
using Workerd = import "/workerd/workerd.capnp";
|
||||
|
||||
const config :Workerd.Config = (
|
||||
services = [
|
||||
(name = "diigo-cache", worker = .cache),
|
||||
(name = "webapp", worker = .webapp),
|
||||
(name = "nowhere", network = (allow = [])),
|
||||
(name = "cache-state", disk = (path = "cache-state", writable = true)),
|
||||
(name = "webapp-state", disk = (path = "webapp-state", writable = true)),
|
||||
],
|
||||
sockets = [
|
||||
(name = "http", http = (), service = "diigo-cache"),
|
||||
],
|
||||
# one JSON object per line, console.* included: journald keeps an
|
||||
# object in one entry rather than one entry per line of it
|
||||
structuredLogging = true,
|
||||
);
|
||||
|
||||
const cache :Workerd.Worker = (
|
||||
compatibilityDate = "@CACHE_DATE@",
|
||||
modules = [
|
||||
@CACHE_MODULES@
|
||||
],
|
||||
durableObjectNamespaces = [
|
||||
(className = "DiigoCache", uniqueKey = "diigo-cache-DiigoCache", enableSql = true),
|
||||
(className = "PublicCache", uniqueKey = "diigo-cache-PublicCache", enableSql = true),
|
||||
],
|
||||
durableObjectStorage = (localDisk = "cache-state"),
|
||||
bindings = [
|
||||
(name = "CACHE_DO", durableObjectNamespace = "DiigoCache"),
|
||||
(name = "PUBLIC_DO", durableObjectNamespace = "PublicCache"),
|
||||
(name = "WEBAPP", service = (name = "webapp", entrypoint = "WebAppFactory")),
|
||||
],
|
||||
# diigo is reached only through WEBAPP
|
||||
globalOutbound = "nowhere",
|
||||
);
|
||||
|
||||
const webapp :Workerd.Worker = (
|
||||
compatibilityDate = "@WEBAPP_DATE@",
|
||||
modules = [
|
||||
@WEBAPP_MODULES@
|
||||
],
|
||||
durableObjectNamespaces = [
|
||||
(className = "WebAppDo", uniqueKey = "webapp-WebAppDo", enableSql = true),
|
||||
],
|
||||
durableObjectStorage = (localDisk = "webapp-state"),
|
||||
bindings = [
|
||||
(name = "WEBAPP_DO", durableObjectNamespace = "WebAppDo"),
|
||||
],
|
||||
# globalOutbound: workerd's default "internet", public addresses only
|
||||
);
|
||||
Reference in new issue
Block a user