Edge Hosting and Cost-Aware CI/CD
The web app runs on Cloudflare Workers and the API on Fly.io, with CI that only runs the checks for the parts that changed.
- Status
- Live
- Layers
- DevOps
- Used by
- Numekara's tech team, and an owner who wants the site fast, safe to update, and cheap to run.
The problem
Server bills and CI minutes can balloon for a small team, while deploying without checks risks breaking the site.
The solution
Next.js is built with OpenNext for Cloudflare Workers, large content is read at build time to keep the bundle small, and the API ships as a Docker image to Fly.io with health checks. CI uses path filters, secret scanning, unit tests, and end-to-end tests.
How it works
What happens, step by step, from the user's point of view.
- 01
A code change is pushed
A developer sends a change to GitHub, usually as a pull request that gets reviewed first.
- 02
Only the relevant checks run
CI looks at which parts changed. If only content changed, API checks are skipped so free GitHub Actions minutes aren't wasted.
- 03
The code is checked automatically
Gitleaks looks for stray passwords, then automated tests and the build run. Browser tests run when a pull request is ready for review.
- 04
The website goes live on Cloudflare
The Next.js site is packaged with OpenNext for Cloudflare Workers. Large content is read at build time to keep the bundle small.
- 05
The API goes live on Fly.io
The API ships as a Docker image. Fly.io runs database updates first and only moves visitors over once the new server passes its health check.
- 06
A smoke test confirms it works
After release, a script checks once more that the main pages and API respond correctly.
System design
Who uses it, what they see, what works behind the scenes, and where the data lives. Read it from left to right.
1Team
- DeveloperSends code changes to GitHub
2Automatic checks
- GitHub Actions CIRuns only the checks for the parts that changed
- GitleaksBlocks a release if a password or key has leaked into the code
- Automated testsVitest, pytest, and Playwright test the web, the API, and browser flows
3Release
- Deploy workflowPublishes the web and API, then runs the smoke test
4Where the app runs
- Cloudflare WorkersRuns the website on Cloudflare's network, close to visitors
- Fly.ioRuns the API in a Docker container with health checks
Key features
- Web on Cloudflare Workers
- Dockerised API on Fly.io
- CI only for changed parts
- Automatic secret scanning
- Rolling deploys with health checks
Built with
- Cloudflare Workers
- OpenNext
- Fly.io
- Docker
- GitHub Actions
- Playwright
- Vitest
- pytest
- Gitleaks
Numbers you can check
- 16.6 MB
- Worker handler size after optimisation (was 102 MB)
- 415
- Web test files (Vitest)
- 117
- API test files (pytest)
What the business gets
- The web bundle shrank from 102 MB to 16.6 MB, so it fits within Cloudflare Workers' limit.
- Free CI minutes aren't spent on checks that aren't needed.
- A broken version is stopped before it reaches visitors.
- Passwords accidentally written into the code are caught before release.
- A new version replaces the old one without taking the site down.
Terms on this page
- CI/CD
- An automatic pipeline that checks every code change and publishes it if it passes.
- Cloudflare Workers
- A service that runs the site across Cloudflare's many data centres, close to visitors.
- Docker
- A way to wrap an app and everything it needs into one package that runs the same anywhere.
- Smoke test
- A quick check after release to make sure the site's main functions still work.
Can it work for your business?
Lean infrastructure for a growing business, with automated checks that keep your site safe whenever it's updated.
Ask about this project