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.
- Make the change in
src/. - Run
npm run build. - Commit the change and the rebuilt bundles and source maps in
dist/together. - Open a pull request.
- Check the Terraform plan on the pull request.
- 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.
- To roll out gradually, set the share of traffic the new version takes in
terraform/rollout.tf. - To go back, name the earlier version in
terraform/rollout.tf. - 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.
| Credential | Used for |
|---|---|
| A Cloudflare Access service token for the media apps | Requests to Sonarr, Radarr and SABnzbd through Cloudflare Tunnel |
| An API key for Sonarr, one for Radarr, and one for SABnzbd | Requests to each app |
| A certificate for Gatehouse's Microsoft Entra ID app | Signing in to Microsoft Entra ID as Gatehouse |
| The log's signing key and fingerprint key | Signing each sealed digest, and fingerprinting values the log must not hold |
| A read token for the log's archive | The 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.
- Open a terminal in a copy of the Gatehouse repository.
- Run
node cli/gatehouse.ts admin preflight, and check that every line passes. - Run
node tools/first_time_config.ts, and read the plan and the restore point it prints. - 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.
- Open a terminal in a copy of the Gatehouse repository.
- Run
node cli/gatehouse.ts login. - 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.