This is a custom Heroku buildpack designed to deploy Node.js applications using Bun runtime, specifically targeting applications in the standalone-api directory.
- Installs Bun runtime (version 1.0.25)
- Automatically detects and uses the
standalone-apidirectory as the working directory - Handles both
bun.lockbandpackage.jsonfiles - Supports build scripts and automatic dependency installation
- Provides fallback startup mechanisms
# Set this buildpack for your Heroku app
heroku buildpacks:set https://github.com/yourusername/yourrepo.git -a your-app-name
# Or add it to existing buildpacks
heroku buildpacks:add https://github.com/yourusername/yourrepo.git -a your-app-name{
"buildpacks": [
{
"url": "https://github.com/yourusername/yourrepo.git"
}
]
}The buildpack expects your project to have one of these structures:
your-project/
├── standalone-api/
│ ├── package.json
│ ├── bun.lockb (optional)
│ └── src/
│ └── index.js
└── ...
Or if standalone-api doesn't exist:
your-project/
├── package.json
├── bun.lockb (optional)
└── src/
└── index.js
- Detection: Checks for
package.jsonorbun.lockbinstandalone-api/or root directory - Bun Installation: Downloads and installs Bun runtime
- Dependency Installation: Runs
bun install --production - Build: Runs
bun run buildif build script exists - Runtime Setup: Creates startup script for production
The buildpack creates a start.sh script that:
- Sets up the PATH to include Bun
- Navigates to
standalone-apiif it exists - Attempts to run the start script:
bun run start - Falls back to the main file specified in
package.json
The buildpack automatically sets:
PATH: Includes the Bun binary location
- Your application must have a
package.jsonfile - For optimal performance, include a
bun.lockbfile - Include a
startscript in yourpackage.jsonor specify amainfield
{
"name": "standalone-api",
"version": "1.0.0",
"main": "src/index.js",
"scripts": {
"start": "bun run src/index.js",
"build": "bun run build-script.js"
},
"dependencies": {
"express": "^4.18.0"
}
}- Build fails: Check that your
package.jsonis valid and dependencies are correctly specified - Start fails: Ensure you have a
startscript or validmainfield inpackage.json - Dependencies not found: Make sure you're using dependencies that are compatible with Bun
This buildpack is designed specifically for applications using Bun runtime with the standalone-api directory structure.