feat!: serve the reference from a Cloudflare Worker - #14
Draft
hbrombeer wants to merge 2 commits into
Draft
Conversation
The reference was published as an nginx container image that grounds-pulumi had to pin, deploy, and route. Hosting the same static build on a Cloudflare Worker removes that chain: the build output is uploaded with the Worker and served from Cloudflare's edge, so a release is a deploy rather than an image bump in another repository. worker/index.ts reproduces the routing contract the nginx configuration provided — base-path redirect, health endpoint, cache classes, application shell fallback, and 404 outside /docs — and worker/index.test.ts covers it. The asset server is configured to resolve exact paths only, because its HTML handling redirects unknown paths to /, which escapes the /docs base path. BREAKING CHANGE: the container image ghcr.io/groundsgg/api-reference is no longer built or published. Deployments move to the Cloudflare Worker apidocs-demo, and the release workflow needs the CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID repository secrets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the nginx container image with a Cloudflare Worker that serves the same static Scalar build, and removes the container tooling that is now unused.
Deployed and verified at https://apidocs-demo.grounds.workers.dev/docs/.
What changed
worker/index.tsowns routing and reads the build output through theASSETSbinding:/and/docsredirect to/docs/,/docs/healthzreturnsok, unknown paths below/docs/fall back to the application shell, everything outside/docsis404. Cache classes match the previous nginx configuration (immutablebundles,max-age=300specs,no-cacheshell).worker/index.test.tscovers that contract (9 cases); CI now builds the Worker bundle withwrangler deploy --dry-runwhere it previously ran the container smoke test.Dockerfile,.dockerignore,nginx/default.conf,scripts/container-smoke.sh, and the GHCR publish job.Note on the asset server
assets.html_handlingmust stay"none". With the default (auto-trailing-slash) the asset server answers unknown paths with a307to/, which escapes the/docsbase path and drops the deep link — reproduced locally before the change.Follow-ups (not in this PR)
CLOUDFLARE_API_TOKEN(Workers Scripts: Edit) andCLOUDFLARE_ACCOUNT_IDmust be added before the release workflow can deploy.api.grounds.gg/docsstill points at the Kubernetes deployment. Moving it means a Worker custom domain or route and removing the image pin ingrounds-pulumi.apidocs-demo; rename before it becomes the production reference.