| title | Cloudflare Container Workers with Go Fiber | ||||
|---|---|---|---|---|---|
| keywords |
|
||||
| description | Run a Go Fiber v3 app in a Cloudflare Container Worker with a Worker proxy. |
This example demonstrates how to use Go Fiber v3 with Cloudflare Container Workers.
- 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
- Bun
- Go 1.25+
- Wrangler CLI
- Cloudflare account with Container Workers access
- Install dependencies:
bun install- Run locally:
bun run dev- Deploy to Cloudflare:
bun run deploy.
βββ 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
- The Worker (TypeScript) receives HTTP requests.
- Requests are forwarded to the Go Fiber container.
- The container responds with JSON data, including environment variables.
The container is configured with:
- 2-minute sleep timeout for inactivity
- Environment variable
MESSAGEpassed from the container class - Port 8080 (default)