Skip to Content
BricoleDocs

Operator CLI

Check an installation, compare generated configuration, preview a deployment, and upgrade a host.

Run these commands from a Bricole checkout after mise install and bun install --frozen-lockfile. Prepare the operator file in a separate configuration repository. Paths passed to the CLI resolve from the current working directory. In these examples, FILE names the installation you intend to operate.

FILE=packages/operator/bricole.example.jsonc
bun run operator help
bun run operator check --config "$FILE"
bun run operator deploy --config "$FILE" --new --dry-run

These commands use fictional values to exercise local checks. Choose your own operator file before a live deploy.

Commands and flags

InvocationWhat it does
bun run operator, help, -h or --helpPrints help for all four commands. Use bun run operator check --help or bun run operator deploy --help for the same output.
bun run operator check --config <file>Requires the operator file. Validates it, builds the shell and facet wrapper, generates the host and optional identity Wrangler configurations, runs a local Wrangler deploy dry run for each, and prints DNS and identity prerequisites.
check --config <file> --diff <wrangler-file>Also prints a key-by-key comparison with an existing Wrangler JSON/JSONC file. The CLI reads that file before regenerating output and matches the Worker name, falling back to the host. A reported difference is information to review.
bun run operator loginInvokes the pinned Wrangler login. Takes no flags or file. The browser authorization step uses the operator’s Cloudflare account.
bun run operator deploy --config <file>Default mode is upgrade. Checks and builds locally, reads the deployed installation, validates the plan, applies identity database migrations where applicable, deploys identity before host, and checks the live host.
deploy --config <file> --newInstalls a new host. Creates unpinned OAuth KV and identity D1 resources when needed. Prints their IDs to save in the operator file. Generates first-deploy secrets. Refuses an already deployed host.
deploy --config <file> --dry-runPlans an upgrade against an assumed matching account. With --new, assumes absent Workers and the existence of the resources you pinned. Writes local Wrangler configuration files. Skips builds, account reads, account writes, lock acquisition and secret generation.
deploy --config <file> --accept-changeAcknowledges specific changes to bindings or identity described below. May also be combined with --new for an interrupted installation or --dry-run to inspect the corresponding plan.
bun run deploy --config <file>Root script alias for bun run operator deploy. Accepts the same deploy flags.
bun run operator wrangler --config <file> <arguments…>Runs the pinned Wrangler under the operator file’s account. The first --config or --config=… selects that file. Use -c for Wrangler’s own configuration and place Wrangler’s subcommand and options after the operator file.

check and deploy --dry-run leave the generated files at apps/host/.deploy/<worker>.json and, when the identity service is configured, apps/identity/.deploy/<identity-worker>.json. Check also leaves the shell in packages/shell/dist/ and the wrapper in apps/host/dist/wrapper/. These are generated outputs. Make installation changes in your operator file.

For example, check the email example, save its generated host configuration, and use it as the baseline when trying the OIDC example. The diff shows which provider the host selects. The plan also lists the identity Worker’s required client secret and callback URI.

bun run operator check --config packages/operator/bricole.example.jsonc
baseline=$(mktemp)
cp apps/host/.deploy/bricole.json "$baseline"
bun run operator check --config packages/operator/bricole.oidc.example.jsonc --diff "$baseline"
rm "$baseline"

First installation and upgrades

Run login and deploy from a private terminal on the intended account. Complete the DNS and provider setup printed by check. For email, the sender domain must have Email Sending enabled. For OIDC, the client must be registered with the callback printed for this host.

  1. Run bun run operator deploy --config "$FILE" --new with your own file. Save the printed operator token, one-time setup code and any returned resource IDs. The token and setup code are shown before Worker deployment. Store them securely even if a later step fails.
  2. Add the returned KV ID to resources.oauthKv and the identity D1 ID to identity.service.database if applicable. Claim the first administrator through the host’s /setup page. The installation guide covers this workflow.
  3. For upgrades, use the original file and Worker names with bun run operator deploy --config "$FILE". An upgrade expects existing Workers and pinned resource IDs. The command serializes concurrent deploys of the same account and host Worker from one checkout with an exclusive lock.
  4. Check the final status. A deploy waits up to three minutes for the host’s /healthz and OAuth issuer. If that check times out, rerun the two requests it prints before attempting another deployment. The Workers may already be serving the release.

A failed first installation can leave resources behind. Use the IDs printed by their creation steps to establish ownership before retrying. A matching resource name alone cannot identify it. If a run stopped after deploying the identity Worker and before deploying the host, inspect the account before adopting that Worker using --new --accept-change.

What an acknowledged change allows

On an upgrade, the planner compares the live OAuth KV binding, identity service binding, sign-in provider, identity D1 binding and OIDC issuer to the file. A change needs --accept-change. Check which sessions, actor identities and stored data the change would reach. For example, replacing an OIDC issuer changes the identity associated with subsequent sign-ins. On Access, --accept-change also reapplies the configured team domain and AUD secrets.

Other refusals require a different remedy. Examples include an unreadable active deployment, split traffic, a deployed Worker missing a required generated secret, a checkout older than a comparable deployed release tag, an unpinned resource on upgrade, a missing identity Worker on upgrade, or a change to the Durable Object class set. Inspect the specific refusal and the live account. A process killed during deployment can leave a lock under apps/host/.deploy/. Confirm the original process has stopped before following the lock recovery instruction.

Credentials and environment

NameSource and lifetime
CLOUDFLARE_ACCOUNT_IDEvery account-pinned Wrangler call uses the account in the operator file. A conflicting inherited value is refused. The pass-through also checks the account in the Wrangler configurations it would read and refuses --temporary.
OPERATOR_TOKENRandom host secret generated on first deploy, used for operator administration. Capture the printed value once. An upgrade leaves the existing secret in place.
SETUP_CODERandom one-time host secret generated on first deploy for the first administrator claim. Keep the code out of the setup URL. It can be removed after use.
AUTH_SECRETRandom secret generated on the first deploy of the identity Worker. Its value stays on that Worker.
ACCESS_TEAM_DOMAIN, ACCESS_AUDHost secrets taken from identity.access for Access deployments. Uploaded if missing and reapplied with --accept-change.
OIDC_CLIENT_SECRETSecret issued by your identity provider. Supply it through the deploy environment the first time the identity Worker needs it. Later upgrades use the existing Worker secret.
CLOUDFLARE_ANALYTICS_TOKENOptional host secret for the admin Usage page. Issue a token with Account Analytics: Read on the configured account and supply it through the deploy environment when enabling analytics.
CREATORSOptional, separately administered host secret. Comma-separated emails give matching verified sign-ins the creator role. Removing an address leaves an already granted role in place.

Use your secret manager or Wrangler’s interactive secret put prompt to supply values. For example, to rotate an existing OIDC client secret, run the following against the identity Worker after coordinating the change with the provider.

bun run operator wrangler --config "$FILE" secret put OIDC_CLIENT_SECRET --name field-station-identity

The example Worker name must match identity.service.worker in your file. Use the host’s worker name when managing CREATORS or the analytics token. The operator strips installation-secret environment variables from child processes. It transfers deploy-time secret values through a restricted temporary secrets file. Protect the first installation’s terminal output, particularly in CI.

For the distinction between operator, service and artifact-scoped publishing credentials, see access control and publishing.