--- # quotesdb-3951 title: '[TRIAGE] Cloudflare Pages build strategy — Pages CI build vs pre-built trunk artifact upload' status: completed type: task priority: critical created_at: 2026-03-10T23:32:12Z updated_at: 2026-03-10T23:32:12Z --- This is a triage decision ticket. It must be resolved before dependent implementation tickets can proceed. Cloudflare Pages build strategy: should the Trunk build run in Cloudflare Pages CI (triggered by git push) or should we upload a pre-built `dist/` artifact via OpenTofu? 1. **Cloudflare Pages CI build** — connect the git repo to Cloudflare Pages; Pages runs `trunk build` on each push. Requires Nix/Rust in the Pages build environment (may need custom build image). 2. **Pre-built artifact upload** — build `dist/` locally or in GitHub Actions, then upload via the Cloudflare Pages API or `wrangler pages deploy`. More control, avoids Pages build env limitations. 3. **Wrangler Pages deploy** — use `wrangler pages deploy dist/` in CI after `trunk build`. **Pre-built artifact + Gitea Actions + `wrangler pages deploy`** (Options 2 + 3 combined). Rationale: - **Pages CI build is not viable**: Cloudflare Pages CI supports Node.js, Python, Ruby, Go — not Rust or Nix. Installing `rustup` + `wasm32` target + `trunk` in a Pages build script is slow (~3–5 min per build), non-reproducible, and fragile. Nix flakes are not available in the Pages build sandbox at all. - **OpenTofu does not upload artifacts**: The `cloudflare_pages_project` resource creates and configures the project, but Terraform/OpenTofu is not designed to upload build artifacts — that is a CD concern, not infrastructure state. - **Gitea Actions + wrangler is the standard pattern**: Gitea Actions uses GitHub Actions-compatible YAML syntax. The workflow builds the Wasm artifact with `trunk build --release` then deploys with `wrangler pages deploy dist/`. Split of responsibilities: - **OpenTofu** (`infra/pages.tf`): create `cloudflare_pages_project` with direct-upload config (no git connection), configure SPA routing, bind custom domain. Run once to provision. - **Gitea Actions** (`.gitea/workflows/deploy-ui.yml`): on push to `quotesdb` branch, build and deploy. Secrets: `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`. Implementation ticket: 5137d7 1. Research the options above and choose the best approach for this project. 2. Update ticket ae886f (Pages project resource) with the chosen strategy. Document the CI/CD flow in `infra/README.md`. 3. Mark this ticket done with a note on the chosen approach in the body or a comment. `chore(quotesdb): resolve triage — pages-build-strategy-gitea-actions-wrangler-deploy`