diffinery/HOMEFLARE.md
| 1 | # Diffinery on Homeflare |
| 2 | |
| 3 | A fork of [codician-team/diffinery](https://github.com/codician-team/diffinery) |
| 4 | whose deploy scripts also work against Homeflare. `main` is upstream's `main` |
| 5 | plus a few commits, each one droppable or fit to send upstream on its own: |
| 6 | |
| 7 | - `CLOUDFLARE_API_BASE_URL` and `CLOUDFLARE_CONTAINER_REGISTRY` in the scripts, |
| 8 | with Cloudflare's API and registry as the defaults. |
| 9 | - The Homeflare deploy described below, skipping the steps that need Cloudflare |
| 10 | itself. |
| 11 | - `scripts/setup.sh` reading the `/login` page before matching it: `curl | grep -q` |
| 12 | fails under `pipefail` when grep stops early. |
| 13 | |
| 14 | Rebase onto upstream when it moves: |
| 15 | |
| 16 | ```sh |
| 17 | git remote add upstream https://github.com/codician-team/diffinery.git |
| 18 | git fetch upstream && git rebase upstream/main |
| 19 | ``` |
| 20 | |
| 21 | ## How it works |
| 22 | |
| 23 | [Homeflare](https://github.com/jason-s13r/homeflare) runs Workers on your own machines (celld) behind a |
| 24 | Cloudflare-compatible API. These scripts deploy to it when `CLOUDFLARE_API_BASE_URL` points at that API, |
| 25 | which `homeflare-wrangler run` sets, along with `CLOUDFLARE_CONTAINER_REGISTRY` (Homeflare's registry) and a |
| 26 | `docker` command on your Podman. |
| 27 | |
| 28 | On another API than Cloudflare's, `scripts/setup.sh` and `scripts/bootstrap.sh` skip what needs Cloudflare |
| 29 | itself: |
| 30 | |
| 31 | | Skipped | What it means | |
| 32 | | --- | --- | |
| 33 | | Zone check | The hostname is a Homeflare custom domain, not a route in a Cloudflare zone. | |
| 34 | | R2 lifecycle rules | Logs, artifacts, archives and exports don't age out by themselves. | |
| 35 | | Email Sending setup and its event subscription | Onboard the sending domain in Cloudflare yourself (Homeflare relays email through it with `HOMEFLARE_EMAIL=cloudflare`). Bounces and complaints don't reach the suppression list. | |
| 36 | | Turnstile widget | Make one in the Cloudflare dashboard and pass its keys: `TURNSTILE_SITE_KEY` and `TURNSTILE_SECRET`. Without them open sign-up and anonymous security reports stay off. | |
| 37 | | Cloudflare Access | Email recovery and the `/auth/access` first sign-in stay off. Passkeys work. | |
| 38 | |
| 39 | ## Deploy |
| 40 | |
| 41 | Put the settings in a file outside the repository (it holds the Turnstile secret), for example |
| 42 | `~/.config/homeflare/diffinery.env`, readable by you only: |
| 43 | |
| 44 | ```sh |
| 45 | CLOUDFLARE_ACCOUNT_ID=<Homeflare's account id> |
| 46 | DIFFINERY_DOMAIN=git.homeflare.example.com |
| 47 | MAIL_DOMAIN=example.com |
| 48 | [email protected] |
| 49 | TURNSTILE_SITE_KEY=0x4AAA... |
| 50 | TURNSTILE_SECRET=0x4AAA... |
| 51 | ``` |
| 52 | |
| 53 | `MAIL_DOMAIN` is a domain onboarded to Email Sending in your Cloudflare account. Homeflare's account id is |
| 54 | in the Dashboard, or from `GET /client/v4/accounts`. Then, from the repository: |
| 55 | |
| 56 | ```sh |
| 57 | homeflare-wrangler --env-file ~/.config/homeflare/diffinery.env run scripts/setup.sh --yes |
| 58 | ``` |
| 59 | |
| 60 | `homeflare-wrangler` reads the Homeflare API token from `~/.config/homeflare/wrangler.env` and sets |
| 61 | `CLOUDFLARE_API_BASE_URL` itself. Run it again to update. |
| 62 | |
| 63 | ## The first administrator |
| 64 | |
| 65 | Without Access, the first account comes from open sign-up, which needs Turnstile and email. Deploy once with |
| 66 | `"SIGNUP": "open"` under `vars` in `apps/diffinery/wrangler.jsonc`, sign up at `https://<host>/signup` with an |
| 67 | address in `BOOTSTRAP_ADMINS`, add a passkey, then remove `SIGNUP` and deploy again. |