02Deployment
Manual deployment
Create the Cloudflare resources yourself and deploy the Worker from your own repository.
Use this method if you maintain a custom fork or prefer not to use InsightFlare Deploy.
Steps
- Fork or clone the InsightFlare repository into your GitHub account.
- Create these resources in Cloudflare:
- A D1 database.
- A KV namespace.
- An R2 bucket. This is optional; see R2 archive.
- Edit
wrangler.tomland replace the placeholdersYOUR_D1_IDandYOUR_KV_IDwith the IDs of the D1 database and the KV namespace. Alternatively, supply the IDs through environment variables so you do not have to edit the file. - Set the secrets
MAIN_SECRETandBOOTSTRAP_ADMIN_PASSWORD. Use the Cloudflare dashboard, or the helper scriptspnpm run ops:secret:mainandpnpm run ops:secret:bootstrap-admin-password. - Import the repository from the Cloudflare Workers page, or deploy from the command line.
What the build does
The Cloudflare build entry points are pnpm run build (build:cf) and pnpm run deploy (deploy:cf). Before building, the prebuild step:
- Applies environment variable overrides to
wrangler.toml. - Applies pending D1 migrations to the remote database.
- Builds the tracker SDK.
If your Cloudflare account has not enabled Analytics Engine, the deployment is retried without the Analytics Engine bindings. See Analytics Engine.
Helper scripts
| Command | Purpose |
|---|---|
pnpm run ops:d1:create | Create the D1 database. |
pnpm run ops:secret:main | Set the MAIN_SECRET Worker secret. |
pnpm run ops:secret:bootstrap-admin-password | Set the BOOTSTRAP_ADMIN_PASSWORD Worker secret. |
pnpm run db:migrate:cf | Apply D1 migrations to the Cloudflare database. |
pnpm run ops:tail | Tail the online Worker logs. |
See the command reference for more.