Heroku buildpack for Bun runtime. Used in production at Lugg.
heroku buildpacks:set https://github.com/lugg/heroku-buildpack-bunYour app must have a bun.lock or bun.lockb file in the root directory.
| Variable | Description | Default |
|---|---|---|
BUN_VERSION |
Pin Bun version (e.g., 1.1.38) |
latest |
BUN_APP_PATH |
Subdirectory for monorepo builds | . |
BUN_FROZEN_LOCKFILE |
Use --frozen-lockfile |
true |
BUN_PRUNE_DEVDEPENDENCIES |
Remove devDeps after build | false |
Pin the Bun version using either:
BUN_VERSIONenvironment variable.bun-versionfile in your repo root
# Via config var
heroku config:set BUN_VERSION=1.1.38
# Or via file
echo "1.1.38" > .bun-versionFor monorepos with Bun workspaces, use --cwd in your Procfile to run from a subdirectory.
Heroku starts dynos from the repo root. Use --cwd to run from your app directory:
web: bun run --cwd apps/server src/index.ts
worker: bun run --cwd apps/server src/worker.ts
release: bun run --cwd apps/server db:migrate
That's it! The buildpack runs bun install from root, which resolves all workspace dependencies.
my-monorepo/
├── apps/
│ └── server/
│ ├── src/index.ts
│ ├── src/worker.ts
│ └── package.json
├── packages/
│ └── shared/
│ └── package.json
├── package.json # workspaces: ["apps/*", "packages/*"]
├── bun.lock
└── Procfile # at root, uses --cwd
Only needed if your app subdirectory has build, heroku-prebuild, or heroku-postbuild scripts:
heroku config:set BUN_APP_PATH=apps/serverThis runs those lifecycle scripts from apps/server/ instead of root.
The buildpack runs these scripts if present in your package.json (or BUN_APP_PATH/package.json for monorepos):
bun install --frozen-lockfilebun run heroku-prebuildbun run buildbun run heroku-postbuild
Create a Procfile at your repo root to define process types:
web: bun run src/index.ts
worker: bun run src/worker.ts
release: bun run db:migrate
For monorepos, use --cwd to run from a subdirectory (see above).
MIT