recipes icon indicating copy to clipboard operation
recipes copied to clipboard

feat: add Cloudflare Container Workers example with Go Fiber v3

Open the-exile-110 opened this issue 5 months ago โ€ข 1 comments

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.

the-exile-110 avatar Jul 08 '25 16:07 the-exile-110

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.

โค๏ธ Share
๐Ÿชง 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 @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

coderabbitai[bot] avatar Jul 08 '25 16:07 coderabbitai[bot]