Skip to content
Gatehouse
Help pages

Set up

How Gatehouse is deployed, the credentials it needs, its first-time settings, the app and the CLI.

Deploy a change

Everything Gatehouse runs on is defined in Terraform, in terraform/ in the Gatehouse repository: the 3 Workers, the D1 databases, the Workers KV namespaces, the log's R2 archive, and the Cron Triggers. The Terraform pipeline plans every pull request and applies it after it merges. main changes only by pull request.

The Workers run the committed bundles dist/index.js, dist/admin.js and dist/log.js, each with its source map.

  1. Make the change in src/.
  2. Run npm run build.
  3. Commit the change and the rebuilt bundles and source maps in dist/ together.
  4. Open a pull request.
  5. Check the Terraform plan on the pull request.
  6. Merge the pull request. The Terraform pipeline applies it.

Roll out gradually, or go back

terraform/rollout.tf sets which version of the Worker code serves traffic.

  1. To roll out gradually, set the share of traffic the new version takes in terraform/rollout.tf.
  2. To go back, name the earlier version in terraform/rollout.tf.
  3. Deploy the change by pull request, as in Deploy a Change.

Credentials Gatehouse needs

Each credential below is held as an encrypted Worker secret, which Terraform sets from the password manager or makes itself and keeps in its encrypted state. No credential is in the repository. The Keys section of the Health tab shows each one's expiry.

CredentialUsed for
A Cloudflare Access service token for the media appsRequests to Sonarr, Radarr and SABnzbd through Cloudflare Tunnel
An API key for Sonarr, one for Radarr, and one for SABnzbdRequests to each app
A certificate for Gatehouse's Microsoft Entra ID appSigning in to Microsoft Entra ID as Gatehouse
The log's signing key and fingerprint keySigning each sealed digest, and fingerprinting values the log must not hold
A read token for the log's archiveThe log API's archive links

Notifications

Gatehouse sends no messages: no email and no push notification, and the app's test notification is not available. Gatehouse raises alerts and shows them on the console's Alerts page (Alerts). A waiting approval shows on Approvals, and a failing service on Health. Every event is in Gatehouse's log.

First-time settings

After Gatehouse moves to Microsoft Entra ID sign-in, its settings name the administrators group and the users group by their object IDs. A script makes the change through the admin API, so each step is recorded like any other change.

  1. Open a terminal in a copy of the Gatehouse repository.
  2. Run node cli/gatehouse.ts admin preflight, and check that every line passes.
  3. Run node tools/first_time_config.ts, and read the plan and the restore point it prints.
  4. Run node tools/first_time_config.ts --apply.

Until the settings name the administrators group, only the bootstrap administrator set in Terraform is let in, and each admission is recorded.

The Gatehouse app

The app is built by Xcode Cloud and tested on every pull request to its repository. It is delivered through TestFlight and installed on the Organization's managed devices through Apple Business Manager and Microsoft Intune. It is not in the App Store.

The Gatehouse CLI

The CLI needs Node 20 or later and nothing else.

  1. Open a terminal in a copy of the Gatehouse repository.
  2. Run node cli/gatehouse.ts login.
  3. Sign in with your Microsoft Entra ID account in the browser window that opens.

The CLI reads its own ID from Gatehouse's published sign-in metadata, so it needs no setting.