feat: add Cloudflare Container Workers example with Go Fiber v3
Description
This PR adds a new recipe demonstrating how to use Go Fiber v3 with Cloudflare Container Workers, a new platform feature that allows running containerized applications on Cloudflare's edge network.
What's included
- Go Fiber v3 application running in a container
- Distroless container image (
gcr.io/distroless/static-debian12) for minimal attack surface - Cloudflare Worker that proxies requests to the container
- Environment variables support for configuration
- Comprehensive documentation with setup instructions
Key Features
- Uses Go Fiber v3 with logger and recover middleware
- Implements a simple JSON API endpoint
- Demonstrates proper container configuration for edge deployment
- Includes optimized Dockerfile with multi-stage build
- Supports Bun as the package manager
Why this recipe?
Cloudflare Container Workers (coming in late June 2025) enable developers to run containerized applications globally on Cloudflare's edge network. This recipe shows how to leverage Go Fiber's performance with Cloudflare's infrastructure for building globally distributed applications.
Testing
The example has been tested locally with:
- Go 1.24+
- Bun
- Wrangler CLI
Summary by CodeRabbit
-
New Features
- Introduced a Go Fiber-based web server that returns JSON responses with environment variables and status.
- Added a Cloudflare Worker script that proxies requests to a containerized Go application using Durable Objects.
- Provided a Dockerfile for building and running the Go-based container application.
- Added configuration for Cloudflare Workers, including Durable Object bindings and container settings.
-
Documentation
- Added a README with setup instructions, project overview, and deployment guidance.
-
Chores
- Introduced a .gitignore file to exclude node_modules from version control.
Walkthrough
A new Cloudflare Workers project directory has been established, featuring a Go Fiber v3 application containerized with Docker, a TypeScript entrypoint integrating with Durable Objects, and comprehensive configuration and documentation. Supporting files include a .gitignore, a wrangler.jsonc for deployment, and a README outlining setup and usage instructions.
Changes
| File(s) | Change Summary |
|---|---|
| cloudflare-workers/.gitignore | Added to ignore node_modules/ directory. |
| cloudflare-workers/Dockerfile | Introduced multi-stage Dockerfile for building and running the Go Fiber app in a distroless container. |
| cloudflare-workers/README.md | Added project documentation with setup, usage, and workflow explanations. |
| cloudflare-workers/container_src/main.go | Added Go Fiber v3 server with JSON API endpoint, environment variable support, and middleware. |
| cloudflare-workers/src/index.ts | Added TypeScript Cloudflare Worker script with Durable Object container, lifecycle hooks, and proxying logic. |
| cloudflare-workers/wrangler.jsonc | Added Cloudflare Worker configuration, container definition, Durable Object binding, and migration setup. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant Worker (index.ts)
participant DurableObject (MyContainer)
participant GoFiberContainer
Client->>Worker (index.ts): HTTP Request "/"
Worker (index.ts)->>DurableObject (MyContainer): getContainer()
Worker (index.ts)->>GoFiberContainer: Proxy HTTP Request
GoFiberContainer-->>Worker (index.ts): JSON Response with env vars
Worker (index.ts)-->>Client: Return JSON Response
Poem
๐
In a warren of code, a worker appears,
With Fiber and Docker, it conquers all fears.
Durable Objects stand ready and bright,
Proxies and configs aligned just right.
A README to guide you, a port set to runโ
Cloudflare and Go, together as one!
โจ Finishing Touches
- [ ] ๐ Generate Docstrings
๐งช Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
๐ชง Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai auto-generate unit teststo generate unit tests for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaior@coderabbitai titleanywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.