Skip to content

Install with the setup script

pnpm self-host:setup is the official way to install and update a self-hosted amabledata. It creates the Cloudflare resources, writes the production configuration, deploys both Workers, generates the secrets and creates the first workspace owner. It is idempotent: you can run it again at any time, and it never overwrites a secret that already exists (the only exception is EDGE_GATEWAY_SECRET when just one of the two Workers has it, see Phase 3).

Before you start, complete the requirements: a Cloudflare account on Workers Paid with R2 enabled, Git, Node.js 20+ and pnpm.

The quickest install, from an empty folder:

Terminal window
git clone https://github.com/Ratne/AmableData.git && cd AmableData
git checkout "$(git describe --tags --abbrev=0)" # latest release tag
pnpm install
pnpm exec wrangler login
pnpm self-host:setup --deploy \
--app-origin https://amable-core.<your-subdomain>.workers.dev \
--edge-origin https://amable-edge.<your-subdomain>.workers.dev \
--owner-email you@example.com --workspace "My company"

At the end the script prints a one-time invitation link. Open it, create your account, set up two-factor authentication, and you are in.

You can read the script before running it: it is scripts/self-host-setup.mjs in the repository.

The script runs four numbered phases and prints each heading:

Phase Printed heading What happens
Check (none) Runs wrangler whoami. If Wrangler is not signed in, it stops with not logged in: run pnpm exec wrangler login first.
1 1/4 Provisioning D1, R2 and queues Creates the D1 database, the R2 bucket and the six queues, or finds them if they already exist.
2 2/4 Writing production wrangler configs Renders the templates in deploy/self-host/ into production configs with the real database ID and your origins.
3 3/4 Build, deploy and secrets Only with --deploy: builds the dashboard, deploys the Workers in the right order and sets the missing secrets.
4 4/4 First owner Only with --deploy and --owner-email: waits for the app to answer, then creates the first workspace and the owner invitation.
Resource Name Command run If it exists
D1 database amable-installation wrangler d1 create amable-installation The ID is read from wrangler d1 list --json
R2 bucket amable-files wrangler r2 bucket create amable-files Error ignored, bucket reused
Queues email-send, events-rollup, webhooks-out, form-submissions, esign-seal, analytics wrangler queues create <name> Error ignored, queue reused

If the database can be neither created nor found, the script stops with could not create or find the D1 database amable-installation.

  • Directoryapps
    • Directorycore
      • wrangler.self-host.jsonc production config of amable-core
    • Directoryedge
      • wrangler.self-host.jsonc production config of amable-edge
      • wrangler.self-host.bootstrap.jsonc same, without the service binding to the core

They are rendered from deploy/self-host/core.wrangler.jsonc and deploy/self-host/edge.wrangler.jsonc, replacing the placeholders __D1_DATABASE_ID__, __APP_ORIGIN__, __EDGE_ORIGIN__ and __CORE_ORIGIN__. Both set ENVIRONMENT=production. The files are rewritten on every run: put permanent changes in the templates, not in the generated files.

Without --app-origin, the script writes placeholder origins (https://amable-core.example.workers.dev, https://amable-edge.example.workers.dev) and prints (no –app-origin: placeholder origins written — rerun with your real URLs before going live).

  1. Version. The script reads the release tag of your checkout with git describe --tags and prints it, for example version: 2026.10.3. Between releases it looks like 2026.10.3-3-gabc1234. Outside a release (no tag) it prints unknown (no release tag: the “new version available” notice stays off). The version is passed to both Workers as APP_VERSION.

  2. Build. pnpm run build:web builds the dashboard (single-page app) into apps/web/dist.

  3. Deploy the edge Worker (bootstrap). wrangler deploy --config apps/edge/wrangler.self-host.bootstrap.jsonc. The first time, amable-core does not exist yet, so the edge is deployed without its service binding to the core and reaches it through CORE_ORIGIN.

  4. Deploy the core Worker. wrangler deploy --config apps/core/wrangler.self-host.jsonc. The core binds to the analytics Durable Object class that lives in the edge Worker, which is why the edge goes first.

  5. Deploy the edge Worker again, this time with the service binding CORE to amable-core.

  6. Secrets. The script lists the existing secrets of both Workers and sets only the missing ones to a fresh random value (32 random bytes, base64):

    Worker Secrets
    amable-core PASSWORD_PEPPER, AUTH_ENCRYPTION_KEY, EMAIL_TOKEN_SECRET, EDGE_GATEWAY_SECRET
    amable-edge EDGE_GATEWAY_SECRET, always the same value as the core’s

    Existing secrets print <worker> <name>: already set, kept (for example core PASSWORD_PEPPER: already set, kept). They are never replaced: a new password pepper would lock every user out.

    EDGE_GATEWAY_SECRET must be equal on both Workers. When only one of them has it (typically a core deployed with the Deploy button and a new edge), the script writes one new random value to both, printing <worker> EDGE_GATEWAY_SECRET: missing on the other worker, both rotated for the Worker that had it. Cloudflare never reveals an existing secret, so it cannot be copied. When both Workers already have it, both values are kept as they are.

  1. The script calls <app-origin>/api/health up to 10 times, 3 seconds apart. The first request also applies the database migrations. If it never answers, it stops with <app-origin>/api/health did not answer: check the deploy, then rerun with –owner-email.

  2. It writes, with wrangler d1 execute amable-installation --remote, the first workspace (name from --workspace, slug derived from it) and an owner invitation for --owner-email in the installation database. Everything happens only while the installation has no users:

    • the workspace is created only when no workspace exists yet; on a rerun the existing first workspace is kept, with its name and slug;
    • any earlier first-owner invitation is deleted, so a rerun issues a new link and the old one stops working;
    • the new invitation is attached to the first workspace.

    Once someone has signed up, nothing is written.

  3. It prints the link, valid for 7 days and shown once:

    Done. Open this link within 7 days to create the owner account (shown once):
    https://amable-core.acme.workers.dev/invite#token=...
    Any earlier first-owner link stops working. If the installation already had users, nothing was created and this link does not work.
  4. Open the link, enter your name (password optional), accept, then set up two-factor authentication (authenticator app or email codes) and save the recovery codes.

The workspace slug is the name lowercased, accents removed, every run of other characters replaced by -, at most 48 characters; if fewer than 2 characters remain, the slug is workspace. “My company” becomes my-company, and the workspace opens at /t/my-company.

  1. Clone the repository and check out the latest release:

    Terminal window
    git clone https://github.com/Ratne/AmableData.git && cd AmableData
    git fetch --tags
    git checkout 2026.10.3 # replace with the latest tag from the releases page
  2. Install the dependencies: pnpm install.

  3. Sign in to Cloudflare: pnpm exec wrangler login. Approve the access in the browser. If your login sees several accounts, select the amabledata account when Wrangler asks, or set CLOUDFLARE_ACCOUNT_ID in your shell first.

  4. Optional dry run, which prints every command without touching anything:

    Terminal window
    pnpm self-host:setup --dry-run --deploy \
    --app-origin https://amable-core.acme.workers.dev \
    --edge-origin https://amable-edge.acme.workers.dev \
    --owner-email you@example.com --workspace "Acme"
  5. Run the same command without --dry-run.

  6. Open the printed invitation link and finish the owner account.

If you prefer to check the generated configs before deploying:

  1. Run pnpm self-host:setup --app-origin ... --edge-origin ... without --deploy. The script stops after phase 2 and prints 3/4 Skipped deploy and secrets. Next: node scripts/self-host-setup.mjs –deploy (same options).

  2. Review apps/core/wrangler.self-host.jsonc and apps/edge/wrangler.self-host.jsonc.

  3. Run it again with --deploy and --owner-email.

If you deployed without --owner-email, the script ends with 4/4 No –owner-email: rerun with –owner-email you@example.com to create the first owner. Rerun the same command adding --owner-email and --workspace. This only works while the installation has no users.

If you lost the invitation link, or it expired, before anyone signed up: rerun the same command with --deploy and --owner-email. The script prints a new link for the same workspace and the old one stops working. Once a user exists, the script creates nothing: ask an owner of the workspace to invite you instead.

Attach custom domains to the Workers (see Connect your domains), then rerun the script with the new --app-origin and --edge-origin. The secrets are kept; only the configs and the deploy change.

Option Value Default Purpose
--app-origin https://host (no path) https://amable-core.example.workers.dev placeholder Public origin of the dashboard and API (APP_ORIGIN): links in emails, OAuth callbacks, CSRF check. Required with --owner-email.
--edge-origin https://host (no path) https://amable-edge.example.workers.dev placeholder Public origin of the edge Worker (EDGE_ORIGIN): tracking snippet, email links, hosted pages.
--core-origin https://host (no path) The value of --app-origin Origin the edge uses to reach the core before the service binding exists (CORE_ORIGIN).
--deploy flag off Build, deploy and set secrets (phases 3 and 4).
--owner-email email none Creates the first workspace and the owner invitation. Lowercased.
--workspace 1 to 120 characters My workspace Name of the first workspace; the slug is derived from it.
--dry-run flag off Prints every Wrangler command ([dry-run] wrangler ...) instead of running it; secrets are shown as <secret on stdin>. No network.
Message Cause
--app-origin needs a value (same for other options) The option is last or followed by another option
appOrigin must be an https origin without a path (also edgeOrigin, coreOrigin) Not https://, or contains a path (a trailing / is removed automatically)
--owner-email must be an email address Malformed email
--owner-email needs --app-origin The invitation link needs the real origin
--workspace must be 1-120 characters Empty or too long name
unknown option <name> Typo in an option

All errors are printed as self-host-setup: <message> and the script exits with code 1.

  • It never overwrites an existing secret, except EDGE_GATEWAY_SECRET when only one of the two Workers has it (both get the same new value).
  • It never creates a second owner on an installation that already has users.
  • It never deletes resources.
  • It does not configure system email, marketing email, OAuth apps, Turnstile or custom domains: see Optional tokens and secrets.
  • Wrangler must be signed in as a member of the Cloudflare account who can create Workers, D1 databases, R2 buckets and queues.
  • The invitation link expires after 7 days and works once. While nobody has signed up, rerunning the script replaces it with a new one (see Get a new first-owner link).
  • The first owner has every permission. See Roles and permissions.
Symptom Cause Fix
not logged in: run pnpm exec wrangler login first Wrangler has no session Run the login, then the script again.
wrangler r2 bucket create prints an error but the script continues Bucket exists (fine) or R2 is not enabled If R2 is not enabled, the deploy fails later: enable R2 and rerun.
wrangler deploy ... failed Usually Workers Paid not active, or a Durable Object or queue limit Read the Wrangler error above the message, fix it, rerun: the script resumes safely.
api/health did not answer The new workers.dev hostname is not live yet, or the deploy failed Open <app-origin>/api/health in a browser; when it answers, rerun with --owner-email.
The invitation link says This invitation is invalid, expired or already used. Already used, expired, or the installation already had users If someone already joined, ask an owner to invite you. If nobody ever signed up (fresh installation), see the next row.
You lost or let expire the first owner link on a fresh installation The link is shown once and lasts 7 days While no user exists, rerun the script with --deploy and --owner-email: it prints a new link for the same workspace and the old one stops working.
An older first-owner link stopped working The script was rerun and issued a new link Use the newest link printed.
Hosted forms, booking pages or tracking fail with gateway errors after a deploy EDGE_GATEWAY_SECRET differs between the two Workers (for example one of them was set by hand) Delete the secret on one Worker (pnpm exec wrangler secret delete EDGE_GATEWAY_SECRET --config apps/edge/wrangler.self-host.jsonc) and rerun with --deploy: both get a new shared value.
Tracking snippets point at amable-edge.example.workers.dev The script ran without --edge-origin Rerun with your real --edge-origin.
version: unknown The checkout is not on a release tag Check out a tag (git checkout <tag>) and rerun if you want the update notice.