Serve built Workers directly through pinned Miniflare with persistent D1-compatible storage and startup migrations. Build and verify Docker images in CI; publish main checkpoints to GHCR for manual TrueNAS updates on port 33046. Preserve explicit public-origin checks and LAN-compatible cryptographic operation IDs. Validation: 5,153 offline tests, typecheck, lint and build; 49 HTTP integration cases; HTTPS-origin create/join/chat/seat protection, foreign-origin rejection, exact saved-seat restart and browser asset serving. Independent persistence/proxy review completed. Clean Docker CI and actual NAS installation follow this source checkpoint.
19 lines
768 B
Bash
19 lines
768 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
# A failed migration must stop startup. Both commands use the same local D1 ID
|
|
# and storage root. Never reset or replace this directory during updates.
|
|
state_path=${DUNE_STATE_PATH:-/data}
|
|
# Validate before migration; this is an administrator setting, not a request header.
|
|
node --input-type=module -e '
|
|
const value = process.env.DUNE_PUBLIC_ORIGIN;
|
|
if (value) {
|
|
const u = new URL(value);
|
|
if (!["http:", "https:"].includes(u.protocol) || u.username || u.password ||
|
|
u.search || u.hash || u.pathname !== "/") throw new Error("Invalid DUNE_PUBLIC_ORIGIN");
|
|
}
|
|
'
|
|
node node_modules/wrangler/bin/wrangler.js d1 migrations apply DB \
|
|
--local --config tools/wrangler.local.json --persist-to "$state_path"
|
|
exec node deploy/serve.mjs
|