ADR-006 — Release Media by Server-Side Copy from the Test Bucket
Status: Accepted Date: 2026-12-06 Authors: Engineering & Architecture Team
Context
Images are kept out of the build and out of Git (ADR-002). Each environment has its own media bucket, served at assets.<domain>, and the built pages link images there. An author uploads images to the non-production bucket only; no person holds a production credential (BRD-INFRA-001). So something in the release itself has to put the images a page needs into the production bucket, and it must be the images that were tested, not whatever happens to be in the test bucket. The test bucket also deletes objects after a few days, to stay within the free plan.
Decision Drivers (FRs & NFRs)
- BRD-005 BR-1.2, BR-1.3 — production receives what was tested, images included.
- BRD-005 BR-2.1, BR-2.2 — test first; nothing reaches production without a person’s release.
- SR-005 SR-F-10, SR-NF-08 — linked images only, checked against the test release, with a credential limited to the two media buckets.
- BRD-002 BR-1.3, BR-3.2 — images stay out of the repository and the build.
Decision — How a release puts its images into the target media bucket
Option 1 — Images in the build
Ship images inside dist/ and let Pages serve them.
Pros:
- No second step and no storage credential.
Cons:
- The build and the repository grow with every image, which BRD-002 rules out.
- Every deploy uploads every image again.
Option 2 — Upload to production by hand
A person uploads to the production bucket the way they upload to the test bucket.
Pros:
- Simple; reuses the upload script.
Cons:
- A person would hold a production credential, which the access model forbids.
- Nothing ties the uploaded images to the tested release.
Option 3 — Download from the test bucket and upload through the pipeline runner
The release job fetches each image from the test environment’s public address and uploads it to the target bucket.
Pros:
- Reading the test bucket needs no credential, since it is public through its address.
Cons:
- Every image passes through the runner’s disk and network on every release.
- Two transfers per image instead of none.
Option 4 — Server-side copy of the linked images from the test bucket (CHOSEN)
The release job lists the images its pages link, checks each exists in the test bucket and is the object the test release recorded, and asks R2 to copy it into the target bucket (S3 CopyObject). A test release copies each linked image onto itself, which restarts its expiry, and records each image’s checksum with the stored build.
Pros:
- Images never pass through the runner; R2 copies them inside the account.
- Production receives exactly the images the tested pages link, checked against the test release, and nothing else.
- Images are in place before the pages that link them are deployed.
- One step and one permission list in both environments.
Cons:
- The production copy credential reads the test bucket: the one permission that crosses environments. It reads only, and only the test bucket’s objects, so nothing in the test environment can reach production.
- A production release more than a few days after the test release can find expired test images and fail; the fix is to upload them and release to test again.
- An image the pages reach only through script at run time is not seen by the link scan.
Final Decision
Option 4. scripts/promote-media.sh runs in app.yml after the build and the comparison and before the Pages deploy, in both environments, with a per-environment media copy credential created in code by the Cloudflare project-setup layer: object read on the test bucket, object write on the environment’s own bucket, nothing else. Options 1 and 2 break the repository and access rules; Option 3 works but moves every image through the runner for no gain. The accepted cost is one cross-environment read permission, limited to the test bucket’s objects, and a release window of a few days between test and production.
Related Documents
- BRD-005 — Controlled Release Promotion
- BRD-002 — Media Asset Delivery and Repository Hygiene
- SR-005 — Release Promotion Pipeline
- ADR-002 — Media Storage Decoupling with Cloudflare R2
- ADR-005 — Separate Pipelines, Released by Hand, One Target per Run
- 00002 — Media Asset Delivery Architecture
- 00006 — GitHub Workflow Architecture