This guide explains how to run the tcoder system locally for development and testing.
- Bun runtime
- Docker
- Cloudflare account (for Workers, R2, Queues)
- Upstash account (for Cloudflare Worker - free tier works)
# For docker-compose (fly-worker)
cp env.local.example .env
# For wrangler dev (Cloudflare Worker)
cp env.local.example .dev.vars
# Then fill in R2 credentials in both filesThe env.local.example file has local Redis values pre-filled:
UPSTASH_REDIS_REST_URL=http://localhost:8079(SRH proxy)UPSTASH_REDIS_REST_TOKEN=local_dev_token
Important: Both .env and .dev.vars should use the same local Redis values for local development. You only need to add:
- R2 credentials (
R2_ACCOUNT_ID,R2_ACCESS_KEY_ID,R2_SECRET_ACCESS_KEY)
Note: For local development, both Cloudflare Worker and fly-worker use the local Serverless Redis HTTP (SRH) proxy that emulates the Upstash API. The fly-worker's Redis URL is also hardcoded in docker-compose.
bun run devThis starts:
- Redis - Local Redis container
- SRH Proxy - Upstash-compatible HTTP API at
http://localhost:8079 - Fly-worker - Docker container polling Redis for jobs
- Wrangler dev - API at
http://localhost:8787 - Scheduled trigger - Hits cron endpoint every 5 minutes
All run together. Press Ctrl+C to stop everything.
┌─────────────────────┐
│ Cloudflare Worker │──── Uses Upstash (production Redis)
│ :8787 │
└─────────────────────┘
┌─────────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Fly-worker │────▶│ SRH Proxy │────▶│ Local Redis │
│ (Docker) │ │ :8079 │ │ (Docker) │
└─────────────────────┘ └─────────────────┘ └─────────────────┘
Local credentials (hardcoded in docker-compose):
- SRH URL:
http://localhost:8079 - SRH Token:
local_dev_token
| Command | Description |
|---|---|
bun run dev |
Start everything (redis + srh + fly-worker + wrangler + trigger) |
bun run fly-worker:build |
Build fly-worker Docker image only |
bun run fly-worker:run |
Run fly-worker container once |
For production, both services connect to Upstash:
Cloudflare Worker (via wrangler secrets):
wrangler secret put UPSTASH_REDIS_REST_URL
wrangler secret put UPSTASH_REDIS_REST_TOKENFly-worker (via fly secrets):
fly secrets set UPSTASH_REDIS_REST_URL=https://your-redis.upstash.io
fly secrets set UPSTASH_REDIS_REST_TOKEN=your-token
fly secrets set R2_ACCOUNT_ID=...
fly secrets set R2_ACCESS_KEY_ID=...
fly secrets set R2_SECRET_ACCESS_KEY=...
fly secrets set R2_OUTPUT_BUCKET_NAME=...Check that all containers are running:
docker ps | grep tcoderYou should see:
tcoder-redistcoder-redis-httptcoder-fly-worker
To reset local Redis data:
docker-compose down -vcurl -X POST http://localhost:8079 \
-H "Authorization: Bearer local_dev_token" \
-H "Content-Type: application/json" \
-d '["PING"]'Should return: {"result":"PONG"}
- The trigger runs every 5 minutes after startup
- First trigger happens 5 seconds after
bun run devstarts - Check console for
[Trigger]log messages