Thumbgen can be deployed to Cloudflare using the Workers + Containers platform. In this setup, a lightweight TypeScript Worker acts as the public-facing entry point and proxies all incoming requests to a containerised instance of the Go service managed by a Durable Object. This gives you a globally distributed front door while keeping the stateful container lifecycle under Cloudflare’s control.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sanskarsharma/thumbgen/llms.txt
Use this file to discover all available pages before exploring further.
Architecture
worker.ts— A minimal Cloudflare Worker that extendsContainerfrom@cloudflare/containers. It declares the default container port (4499), asleepAfteridle timeout, and lifecycle hooks (onStart,onStop,onError). The defaultfetchhandler simply forwards every request to the container viagetContainer(env.THUMBGEN_CONTAINER).fetch(request).ThumbgenContainer— A Durable Object class that wraps the running Go container. It is referenced inwrangler.jsoncunder bothcontainersanddurable_objects.bindings.wrangler.jsonc— Declares the container image (built from the localDockerfile), the Durable Object binding, and an optional custom domain route.
Prerequisites
- A Cloudflare account with Workers + Containers access.
- Wrangler CLI — Cloudflare’s deployment tool, installed via npm.
Deployment Steps
Install dependencies
Install the required npm packages (including
@cloudflare/containers and Wrangler):Configure your custom domain
Open Replace
wrangler.jsonc and update the routes section with your own domain, or remove the entry entirely if you want to use Cloudflare’s default *.workers.dev subdomain:thumbgen.pohawithpeanuts.com with your own domain (which must already be active on Cloudflare), or delete the routes block to deploy without a custom domain.Deploy to Cloudflare
Deploy the Worker and container to your Cloudflare account:Wrangler will build the container image from the local
Dockerfile, push it to Cloudflare’s registry, and publish the Worker. Once complete, your service will be live at the configured custom domain or your *.workers.dev URL.Worker Source (worker.ts)
sleepAfter = "5m" property instructs Cloudflare to automatically suspend the container after 5 minutes of inactivity. This keeps costs low for low-traffic deployments — the container is woken up automatically on the next incoming request with a short cold-start delay.
Wrangler Configuration (wrangler.jsonc)
The key sections of wrangler.jsonc that govern the Cloudflare deployment:
The
max_instances field under containers is set to 1. This means only a
single container instance will ever run at a time. For most thumbnail workloads
this is sufficient, but if you expect high concurrency you can increase this
value and Cloudflare will scale the container pool accordingly.