You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
2.7 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

+++
title = "[TRIAGE] Cloudflare Pages build strategy — Pages CI build vs pre-built trunk artifact upload"
priority = 8
status = "done"
ticket_type = "task"
dependencies = []
+++
<context>
This is a triage decision ticket. It must be resolved before dependent implementation tickets can proceed.
</context>
<question>
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?
</question>
<options>
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`.
</options>
<decision>
**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 (~35 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
</decision>
<resolution>
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.
</resolution>
<commit>
`chore(quotesdb): resolve triage — pages-build-strategy-gitea-actions-wrangler-deploy`
</commit>