This buildpack builds on top of the existing Node.js Engine Cloud Native Buildpack. It runs subsequent scripts after Node is install.
- Run automatically
yarn install
- Run when configured in
package.json
yarn build
oryarn heroku-postbuild
Using brew
(assuming development is done on MacOS), install pack
.
brew tap buildpack/tap
brew install pack
If you're using Windows or Linux, follow instructions here.
Right now, we are prototyping with a local version of the buildpack. Clone it to your machine.
git clone git@github.com:heroku/nodejs-yarn-buildpack.git
Clone the Heroku Node.js Engine Cloud Native Buildpack.
cd .. # change from nodejs-npm-buildpack directory
git clone git@github.com:heroku/nodejs-engine-buildpack.git
Using pack, you're ready to create an image from the buildpack and source code. You will need to add flags that point to the path of the source code (--path
) and the paths of the buildpacks (--buildpack
).
cd nodejs-yarn-buildpack
pack build TEST_IMAGE_NAME --path ../TEST_REPO_PATH --buildpack ../nodejs-engine-buildpack --buildpack ../nodejs-yarn-buildpack
You can also create a builder.toml
file that will have explicit directions when creating a buildpack. This is useful when there are multiple "detect" paths a build can take (ie. yarn vs. npm commands).
In a directory outside of this buildpack, create a builder file:
cd ..
mkdir heroku_nodejs_builder
touch heroku_nodejs_builder/builder.toml
For local development, you'll want the file to look like this:
[[buildpacks]]
id = "heroku/nodejs-engine-buildpack"
uri = "../nodejs-engine-buildpack"
[[buildpacks]]
id = "heroku/nodejs-yarn-buildpack"
uri = "../nodejs-yarn-buildpack"
[[order]]
group = [
{ id = "heroku/nodejs-engine-buildpack", version = "0.0.1" },
{ id = "heroku/nodejs-yarn-buildpack", version = "0.0.1" }
]
[stack]
id = "heroku-18"
build-image = "heroku/pack:18"
run-image = "heroku/pack:18"
Create the builder with pack
:
pack create-builder nodejs --builder-config ../heroku-nodejs-builder/builder.toml
Now you can use the builder image instead of chaining the buildpacks.
pack build TEST_IMAGE_NAME --path ../TEST_REPO_PATH --builder nodejs
- buildpacks: provide framework and a runtime for source code. Read more here.
- OCI image: OCI (Open Container Initiative) is a project to create open sourced standards for OS-level virtualization, most importantly in Linux containers.