Cloud deployment decisions
Decide whether Bun is the runtime, build tool, or package manager on the target platform
Last updated on
Ask one question first
“Supports Bun” may only mean that a platform can run bun install; it does not guarantee that Bun handles production requests. Identify the build environment and the request runtime separately.
| Target | Bun's actual role | Recommended entry | Main boundary |
|---|---|---|---|
| Docker / Cloud Run / ECS / Kubernetes | Real runtime inside a container | bun run src/index.ts | Honor the platform port, signals, probes, and limits |
| AWS Lambda container | Bun plus Lambda Web Adapter | Container image | Adapt the event model; Bun's guide uses PORT=8080 |
| Vercel Functions | Bun runtime (bunVersion) | Supported framework entry | Bun.serve is unsupported; Next.js still bundles with Turbopack/Webpack |
| Cloudflare Workers | Package manager and local tooling | bunx wrangler deploy | Production runs on workerd; do not assume Bun.* exists |
| Static site / CDN | Build tool | bun run build | Production serves artifacts, not a Bun process |
Local success is not platform compatibility
A successful bun run dev only validates the local toolchain. Acceptance on the target runtime must cover startup, networking, filesystems, native dependencies, signals, timeouts, and scaling.
Pick a path
Containers & orchestration
Images, non-root users, ports, probes, shutdown, and secrets.
Serverless & edge
Runtime differences across Lambda, Vercel, Workers, and AI streams.
Production engineering baseline
TypeScript, CI, dependency security, environment, and release gates.
Production AI apps
Streaming, tool calls, observability, safety, and evaluations.
Platform guides
Deploy to AWS Lambda
Container image + Lambda Web Adapter; the service listens on 8080.
Deploy to Vercel
Enable the Bun runtime with bunVersion; the extra Next.js scripts.
Deploy to Cloudflare Workers
Bun runs the toolchain, workerd runs production; the full Wrangler flow.
Platform-independent release gates
- Pin Bun or use a controlled version range, and commit
bun.lock. - Build production dependencies with
bun install --frozen-lockfile --production. - Run type checks, tests, and smoke tests in the production image.
- Run as a non-root user and treat local state as replaceable.
- Give readiness, liveness, and startup probes distinct meanings.
- Inject credentials from a secret manager; never bake them into images, logs, or agent context.
- Test SIGTERM, rolling deployment, rollback, and migration ordering.
Official references: Bun Docker guide, Bun deployment guides, and Cloudflare Wrangler.