Deploying Fiber
Fiber is two Workers in your Cloudflare account: <name>-api serves the UI and the API, and
<name>-engine keeps runs, their logs and the queue of steps. They share a D1 database, and the engine
keeps logs and artifacts in two R2 buckets. Steps run on runners you start (runner).
You need a Cloudflare account on the Workers Paid plan, with R2 turned on; Node 24 and pnpm; and a clone of this repository. Every command below is run from the top of the clone, unless it says otherwise.
pnpm installpnpm --filter @fiber/api exec wrangler loginWrangler uses CLOUDFLARE_API_TOKEN in place of that login when it is set in your shell. Such a token
needs to edit Workers, D1 and R2, or wrangler d1 create fails with an authentication error: unset it
while deploying, or give it those permissions.
1. Choose a name and an address
Section titled “1. Choose a name and an address”The name is that of each of the deployment’s parts: lower-case letters, digits and -, such as ci. The
address is where people will reach Fiber: a custom domain on a zone of the account, such as
https://ci.example.com, or https://<name>-api.<your subdomain>.workers.dev. wrangler whoami does not
say the subdomain; the dashboard does, under Workers & Pages.
NAME=ciURL=https://ci.example.com2. Make the database and the buckets
Section titled “2. Make the database and the buckets”cd apps/apipnpm exec wrangler d1 create $NAME # prints the database's idpnpm exec wrangler r2 bucket create $NAME-logspnpm exec wrangler r2 bucket create $NAME-artifactscd ../..3. Write the configuration
Section titled “3. Write the configuration”pnpm --filter @fiber/api deploy-config --name $NAME --url $URL --database-id <the id>It writes apps/api/wrangler.deploy.json and apps/engine/wrangler.deploy.json from the committed
wrangler.jsonc of each, with this deployment’s names: the Workers, database, buckets, Workflow and
metrics dataset; its own rate-limit namespaces, so that two deployments in an account do not share
counters; its address as FIBER_AUTH_ORIGINS and FIBER_PUBLIC_URL; and a route to the custom domain,
or workers.dev. Git ignores both files. Write them again after each update of the repository, before
deploying it.
4. Make the tables
Section titled “4. Make the tables”cd apps/apipnpm exec wrangler d1 migrations apply DB --remote -c wrangler.deploy.jsoncd ../..5. Settings
Section titled “5. Settings”Keep the settings in two files outside the repository, readable only by you, and never commit them:
mkdir -p ~/.config/fiber/$NAME && chmod 700 ~/.config/fiber ~/.config/fiber/$NAME && cd ~/.config/fiber/$NAMEumask 077KEY=$(openssl rand -hex 32)printf 'FIBER_SECRETS_KEY=%s\n' "$KEY" > engine.envprintf 'FIBER_SECRETS_KEY=%s\nFIBER_PASSWORD_SIGN_IN=on\nFIBER_ADMIN_PASSWORD=%s\n' \ "$KEY" "$(openssl rand -base64 24)" > api.envcd -FIBER_SECRETS_KEYencrypts project secrets, and is the same on both Workers. Keep a copy elsewhere: without it the stored secrets cannot be read (secrets).FIBER_PASSWORD_SIGN_INandFIBER_ADMIN_PASSWORDlet you sign in asadminwith that password. To sign in with GitHub as well or instead, add its settings toapi.env(sign-in).- Other settings go in the same files: limits and retention in
engine.env(storage),FIBER_METRICS_TOKENinapi.env(metrics). NotFIBER_AUTH_ORIGINSorFIBER_PUBLIC_URL: the configuration has those.
They are stored as the Workers’ secrets when each is deployed with its file, and kept by later deploys that are not given one. A variable of the same name in your shell’s environment wins over the file’s, so have none set while deploying.
6. Deploy
Section titled “6. Deploy”The engine first: the API calls it.
pnpm --filter @fiber/web buildcd apps/enginepnpm exec wrangler deploy -c wrangler.deploy.json --secrets-file ~/.config/fiber/$NAME/engine.envcd ../apipnpm exec wrangler deploy -c wrangler.deploy.json --secrets-file ~/.config/fiber/$NAME/api.envcd ../..A custom domain is made by the API’s deploy, with its DNS record and certificate; the first request may wait a minute for the certificate.
7. Check it
Section titled “7. Check it”curl $URL/health # {"status":"ok"}curl $URL/ready # {"status":"ready"}; a 503 names what is wrong in the API's logsThen, at $URL, sign in as admin with the password in api.env, and change it in Settings. Once
it is changed, take FIBER_ADMIN_PASSWORD out of api.env and remove it from the Worker:
cd apps/api && pnpm exec wrangler secret delete FIBER_ADMIN_PASSWORD -c wrangler.deploy.json && cd ../..To run a step, build the command line, make a project and an agent, and start a runner:
pnpm --filter @fiber/cli build && pnpm --filter @fiber/runner buildalias fiber="node $PWD/apps/cli/dist/fiber.js"export FIBER_API_URL=$URLfiber login --username adminfiber projects create demo # prints the project's idTOKEN=$(fiber agents create --project <project id> --name laptop --labels os=linux)FIBER_AGENT_TOKEN=$TOKEN FIBER_AGENT_ALLOW_HOST_SHELL=true fiber agent \ --runner apps/runner/dist/fiber-runner.js --workspace ~/fiber-workspacesIn another terminal, apply an example and run it:
fiber pipelines apply examples/fiber.yml --project <project id> # prints the pipeline's idfiber run <pipeline id> --followUpdating
Section titled “Updating”git pull && pnpm installpnpm --filter @fiber/api deploy-config --name $NAME --url $URL --database-id <the id>cd apps/api && pnpm exec wrangler d1 migrations apply DB --remote -c wrangler.deploy.json && cd ../..pnpm --filter @fiber/web build(cd apps/engine && pnpm exec wrangler deploy -c wrangler.deploy.json)(cd apps/api && pnpm exec wrangler deploy -c wrangler.deploy.json)Migrations only add, so the Workers that are running go on working while they are applied. Runs go on through a deploy: their state is in Durable Objects, and runners reconnect.
Not yet
Section titled “Not yet”Cloud runners (apps/containers) are not ready to deploy. The docs site (apps/docs) is static, and
deploys with pnpm --filter @fiber/docs build and then wrangler deploy in apps/docs, once
wrangler.jsonc there has a route.