Skip to content

jakeg/heroku-buildpack-bun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

heroku-buildpack-bun

Heroku buildpack for Bun.js - allows you to run Bun on Heroku.

Largely copied from the Deno buildpack.

How to use

To add the buildpack to your Heroku app, visit the settings page for your app on Heroku, then under 'Buildpacks' add the URL https://github.com/jakeg/heroku-buildpack-bun.

You'll need a Procfile in the root folder of your app, with eg web: bun index.js in it.

Pin a certain Bun version with a runtime.bun.txt or runtime.txt with e.g. v1.0.7 in it.

Binding to correct port

Bind to env.PORT eg

import { env } from 'process'

const server = Bun.serve({
  port: env.PORT || 3000,
  fetch(request) {
    return new Response(`Welcome to Bun running on Heroku!`)
  },
})

console.log(`Listening on localhost:${server.port}`)

Potential issues

Be aware that Heroku doesn't use a new enough version of the Linux kernel to support io_uring, which is needed for Bun.write(). Use node:fs.writeFile() instead. - this seems now to be fixed.

Use the Issues tab to report any issues.

About

Heroku buildpack for Bun.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages