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.

69 lines
2.8 KiB
Markdown

+++
title = "Define Cloudflare Pages project resource — build config, output dir, git repo connection or artifact upload"
priority = 7
status = "done"
ticket_type = "task"
dependencies = ["2d1371", "fc9bfd"]
+++
<context>
Infrastructure is managed with OpenTofu using the Cloudflare provider. Configuration lives in `infra/`. Resources include a Cloudflare Worker (API), Cloudflare D1 database (bound to the worker), and a Cloudflare Pages project (UI frontend).
Build strategy resolved in triage fc9bfd: **pre-built artifact + Gitea Actions + `wrangler pages deploy`**. Pages CI build is not used. The `cloudflare_pages_project` resource is configured for direct upload (no git connection). The actual artifact deployment is handled by `.gitea/workflows/deploy-ui.yml` (ticket 3781c9).
</context>
<goal>
Define the Cloudflare Pages project resource in `infra/pages.tf`:
1. `cloudflare_pages_project` resource named `quotesdb-ui`
2. Set `production_branch = "quotesdb"` (the integration branch)
3. Configure `deployment_configs` with `production.compatibility_date` and `production.d1_databases` if needed
4. Do NOT configure a git source block — this project uses direct upload
Every block must have a comment explaining its purpose.
</goal>
<constraints>
- Do NOT add a `source` block to the Pages project (no git-connected build — direct upload only).
- SPA routing (triage e2bd9b) is resolved: a `_redirects` file (`/* /index.html 200`) is included
in the Trunk build output via `<link data-trunk rel="copy-file" href="_redirects"/>` (ticket 9ef703).
No changes are needed in the OpenTofu Pages resource — Cloudflare Pages processes `_redirects`
automatically from the uploaded `dist/` directory.
- The output directory (`dist/`) is a Trunk convention; it is documented here for reference but not configured in OpenTofu (wrangler handles it at deploy time).
- The Pages project name `quotesdb-ui` must match the name used in `wrangler pages deploy --project-name quotesdb-ui`.
</constraints>
<reference>
```hcl
# infra/pages.tf
# Cloudflare Pages project for the quotesdb Yew/Wasm frontend.
# Uses direct upload — artifacts are deployed via wrangler in Gitea Actions (ticket 3781c9).
resource "cloudflare_pages_project" "ui" {
account_id = var.cloudflare_account_id
name = "quotesdb-ui"
production_branch = "quotesdb"
# Deployment configuration for the production environment.
deployment_configs {
production {
compatibility_date = "2024-01-01"
# SPA routing: handled by dist/_redirects (/* /index.html 200) — see ticket 9ef703.
}
}
}
```
</reference>
<validation>
Run from the `infra/` directory:
```sh
tofu validate
tofu plan
```
</validation>
<commit>
`feat(quotesdb): define Cloudflare Pages project resource in OpenTofu`
</commit>