Skip to content

Latest commit

Β 

History

History
78 lines (56 loc) Β· 2.24 KB

File metadata and controls

78 lines (56 loc) Β· 2.24 KB
title Cloudflare Container Workers with Go Fiber
keywords
cloudflare
container
worker
edge
description Run a Go Fiber v3 app in a Cloudflare Container Worker with a Worker proxy.

Cloudflare Container Workers with Go Fiber

Github StackBlitz

This example demonstrates how to use Go Fiber v3 with Cloudflare Container Workers.

Features

  • Go Fiber v3 framework
  • Distroless container for minimal attack surface (gcr.io/distroless/static-debian12)
  • JSON API response
  • Environment variables support
  • Logger and Recover middleware

Prerequisites

  • Bun
  • Go 1.25+
  • Wrangler CLI
  • Cloudflare account with Container Workers access

Getting Started

  1. Install dependencies:
bun install
  1. Run locally:
bun run dev
  1. Deploy to Cloudflare:
bun run deploy

Project Structure

.
β”œβ”€β”€ src/index.ts           # Worker entry point
β”œβ”€β”€ container_src/
β”‚   β”œβ”€β”€ main.go           # Go Fiber application
β”‚   β”œβ”€β”€ go.mod            # Go module file
β”‚   └── go.sum            # Go dependencies
β”œβ”€β”€ Dockerfile            # Container configuration
└── wrangler.jsonc        # Cloudflare Workers configuration

How it Works

  1. The Worker (TypeScript) receives HTTP requests.
  2. Requests are forwarded to the Go Fiber container.
  3. The container responds with JSON data, including environment variables.

Container Configuration

The container is configured with:

  • 2-minute sleep timeout for inactivity
  • Environment variable MESSAGE passed from the container class
  • Port 8080 (default)

Learn More