Cloud Foundry Node.js Buildpack
A Cloud Foundry buildpack for Node based apps.
This is based on the [Heroku buildpack] (https://github.com/heroku/heroku-buildpack-nodejs).
Additional documentation can be found at the CloudFoundry.org.
Usage
This buildpack will get used if you have a package.json
file in your project's root directory.
cf push my_app -b https://github.com/cloudfoundry/buildpack-nodejs.git
Specify a node version
Set engines.node in package.json to the semver range (or specific version) of node you'd like to use. (It's a good idea to make this the same version you use during development)
"engines": {
"node": "0.11.x"
}
"engines": {
"node": "0.10.33"
}
OpenSSL support
Since November 2015, the nodejs-buildpack has been packaging binaries of Node.js® with OpenSSL that are statically linked. With community approval, it was decided to support Node.js® 4.x and greater, which relied on the Node.js® release cycle to provide OpenSSL updates.
The buildpack's team binary-builder was updated to enable the static openssl compilation. All versions of Node.js® compiled since have been statically linked with OpenSSL, which include versions of Node.js® greater than and equal to 0.12.10 and 0.10.42.
Disconnected environments
To use this buildpack on Cloud Foundry, where the Cloud Foundry instance limits some or all internet activity, please read the Disconnected Environments documentation.
Vendoring app dependencies
As stated in the Disconnected Environments documentation, your application must 'vendor' it's dependencies.
For the NodeJS buildpack, use npm
:
cd <your app dir>
npm install # vendors into /node_modules
cf push
uploads your vendored dependencies.
Additional extensions
In cached mode, use the semver node_module (as opposed to http://semver.io) to resolve the correct node version. The semver.io service has an additional preference for stable versions not present in the node module version. We wrap the node module using lib/version_resolver.js to add back this functionality.
Building
- Make sure you have fetched submodules
git submodule update --init
- Get latest buildpack dependencies
BUNDLE_GEMFILE=cf.Gemfile bundle
- Build the buildpack
BUNDLE_GEMFILE=cf.Gemfile bundle exec buildpack-packager [ --cached | --uncached ]
- Use in Cloud Foundry
Upload the buildpack to your Cloud Foundry and optionally specify it by name
cf create-buildpack custom_node_buildpack node_buildpack-offline-custom.zip 1
cf push my_app -b custom_node_buildpack
Supported binary dependencies
The buildpack only supports the stable patches for each dependency listed in the manifest.yml and releases page.
If you try to use a binary that is not currently supported, staging your app will fail and you will see the following error message:
Could not get translated url, exited with: DEPENDENCY_MISSING_IN_MANIFEST: ...
!
! exit
!
Staging failed: Buildpack compilation step failed
Testing
Buildpacks use the Machete framework for running integration tests.
To test a buildpack, run the following command from the buildpack's directory:
BUNDLE_GEMFILE=cf.Gemfile bundle exec buildpack-build
More options can be found on Machete's Github page.
Contributing
Find our guidelines here.
Help and Support
Join the #buildpacks channel in our [Slack community] (http://slack.cloudfoundry.org/)
Reporting Issues
Open an issue on this project
Active Development
The project backlog is on Pivotal Tracker