Deployment

Deploy on Cloudflare Workers Free

Davloom runs on the Workers Free plan without a payment method: the Worker serves the Dashboard and WebDAV, D1 keeps the records (the administrator, API Keys, Mounts, locks), and each storage backend is one SQLite-backed Durable Object that keeps file content in 1 MiB rows.

Limits of the Free plan

LimitWhat it means for Davloom
100 MB request bodyA single upload is at most 100 MB; WebDAV PUT above it fails with 413.
1 GB per Durable ObjectOne storage backend holds about 1 GB. Add more backends for more.
5 GB of Durable Object storage per accountAll backends together.
100,000 Durable Object rows written per dayAbout 100 GB of uploads a day at 1 MiB a row, fewer with many small files.
D1: 5 million rows read and 100,000 written per dayAPI Keys are cached for 30 s, so a WebDAV client costs few reads.
R2 and S3-compatible backends are optional. Enabling R2 needs a payment method; Davloom offers the R2 kind only when the Worker has an R2 binding.

Deploy with the button

Deploy to Cloudflare
The button needs only a Cloudflare account and a GitHub or GitLab account. It:
  1. Copies this repository into a new repository in your GitHub or GitLab account.
  2. Reads wrangler.jsonc at the repository root and creates what it names in your Cloudflare account: the Worker (davloom unless you rename it), a D1 database (davloom unless you rename it), and the Durable Object namespace that holds files. It writes the new database's id into the copy's wrangler.jsonc.
  3. Asks for the secret DAVLOOM_SECRET, listed in .dev.vars.example. Use at least 32 random bytes, for example from openssl rand -base64 48, and keep a copy: changing it later signs everyone out and makes stored S3 secret keys unreadable. The value the form suggests is a placeholder that is too short on purpose, so a Worker deployed with it answers every API and WebDAV request with an error instead of running with a published secret.
  4. Connects the new repository to Workers Builds, which runs bun run build (the Dashboard) and bun run deploy. That applies the D1 migrations by the binding name, DB, and then deploys with the root wrangler.jsonc. Each push to the new repository deploys again the same way.
The root wrangler.jsonc is apps/api/wrangler.jsonc with paths taken from the repository root, without the project's custom domain and with a placeholder D1 database id; scripts/root-wrangler-config.test.ts keeps the two in step. Workers Builds installs with the Bun that packageManager in package.json names.
Once the deploy finishes, open the Worker's address, https://davloom.<your subdomain>.workers.dev, and create your account right away: the first account becomes the owner, and registration closes for everyone once it exists. Until then anyone who finds the address could register first. The button cannot set the optional DAVLOOM_SETUP_TOKEN before the first deploy; if you cannot register at once, add it as a secret under the Worker's Settings > Variables and Secrets first.
To answer on your own domain, open the Worker in the Cloudflare dashboard and add the domain under Settings > Domains & Routes > Add > Custom domain (the domain's zone must be on the same account). Then add the plain variable DAVLOOM_URL, such as https://files.example.com, under Settings > Variables and Secrets: passkeys need it, and keep_vars keeps it across later deploys. To keep the domain in code instead, add a routes entry to your copy's wrangler.jsonc, as apps/api/wrangler.jsonc does.
The button flow has not been run end to end by the project yet: bun run build and the Worker's bundle (wrangler deploy --dry-run with the root config) are tested, and the root config runs in local workerd, but how the button fills the D1 database id, its secret form, and whether a custom domain added in the dashboard survives the next build are as Cloudflare's documentation describes them, not tested.

Deploy by hand

You need Bun and a Cloudflare account. From a clone of the repository, build the Dashboard first (from the repository root, so the build runs on Bun):
bash
bun install --frozen-lockfile
bun run --filter @davloom/web build
cd apps/api
bunx --bun wrangler login
apps/api/wrangler.jsonc describes the project's own deployment. Before you deploy your own, edit it:
  • Delete the routes entry, which names the project's custom domain, or replace its pattern with a domain on your account. Without a route the Worker answers on davloom.<you>.workers.dev.
  • Replace the D1 database_id with the id of the database you create next.
Create the D1 database and put its id into apps/api/wrangler.jsonc under d1_databases:
bash
bunx --bun wrangler d1 create davloom
Apply the migrations and deploy:
bash
bunx --bun wrangler d1 migrations apply davloom --remote
bunx --bun wrangler deploy
Set the secret. DAVLOOM_SECRET signs sessions and encrypts S3 secret keys; use at least 32 random bytes and keep it: changing it signs everyone out and makes stored S3 secret keys unreadable.
bash
openssl rand -base64 48 | bunx --bun wrangler secret put DAVLOOM_SECRET
Open the Worker's address right after deploying and create your account: registration is open only while the instance has no account, so the first visitor becomes the owner, and it closes for everyone, permanently, once the owner exists. Then create an API Key on Credentials and mount https://<worker>/dav/; Finder also takes https://<worker>, whose WebDAV requests the Worker redirects to /dav/. Registration creates a Durable Objects backend and the Mount files.
Until you register, anyone who finds the address could register first. To close that window, set the optional secret DAVLOOM_SETUP_TOKEN before you deploy: registration, and importing an export in its place, then ask for it. Without it, register right after deploying.
bash
openssl rand -base64 32 | tee /dev/stderr | bunx --bun wrangler secret put DAVLOOM_SETUP_TOKEN
Davloom refuses passwords shorter than 12 characters and passwords that appear in known breaches, which it checks with the Have I Been Pwned range API (api.pwnedpasswords.com; only the first five characters of the password's SHA-1 hash leave the server). When that API cannot be reached, Davloom refuses the new password with password_check_failed (503) rather than accept it unchecked. DAVLOOM_CHECK_LEAKED_PASSWORDS=off (a plain variable) turns the check off, for an instance without internet access.
DAVLOOM_URL (a plain variable) names the public address, such as https://davloom.example.workers.dev or a custom domain. Set it: passkeys are bound to it and are off without it, and once it is set the API accepts changes only from pages on that address. Without it, the API accepts changes from the address each request was sent to.
Sign-in is rate limited in D1 by the client's address, and step-up verification locks for 15 minutes after five wrong passwords or authenticator codes.

Deploying from GitHub

.github/workflows/deploy.yml deploys every push to main once the repository has the secrets CLOUDFLARE_API_TOKEN (Workers Scripts Edit, D1 Edit, Account Settings Read, and Workers Routes Edit for a custom domain) and CLOUDFLARE_ACCOUNT_ID. Without them it succeeds without deploying.

Smoke test

scripts/smoke.ts checks a running deployment end to end with one Read/Write API Key. It loads the Dashboard, checks the setup state and the Basic challenge, and runs a WebDAV round trip: a 1 MiB file, a byte range, a dead property, a lock and copy and move, in a new folder of the first Mount that it deletes at the end.
bash
DAVLOOM_SMOKE_KEY=dav_… bun scripts/smoke.ts https://davloom.example.com
The Deploy workflow runs it after each deploy when the repository has a DAVLOOM_SMOKE_KEY secret and a DAVLOOM_SMOKE_URL variable. The same check runs against a Docker deployment, and the compatibility tests run it against local workerd and the Bun and RustFS stack.