The Node Function Buildpack is a Cloud Native Buildpack V3 that provides the riff Node Function Invoker to functions.
This buildpack is designed to work in collaboration with other buildpacks, which are tailored to support (and know how to build / run) languages supported by riff.
In a nutshell, when combined with the other buildpacks present in the riff builder what this means (and especially when dealing with the riff CLI which takes care of the creation of the riff.toml file for you):
- The presence of a
package.jsonfile and/or the fact that the--artifactflag points to a.jsfile will result in- the
npm installation (oryarn installation) of the function if applicable - the execution as a node function thanks to the node invoker
- the
- Ambiguity in the detection process will result in a build failure
- The presence of the
--invokerflag will entirely bypass the detection mechanism and force a given language/invoker
Detection passes if
- a
$APPLICATION_ROOT/riff.tomlexists and - the build plan already contains a
npmkey (typically because an NPM based application was detected by the npm buildpack)- alternatively, if the file pointed to by the
artifactvalue inriff.tomlexists and has a.jsextension
- alternatively, if the file pointed to by the
If detection passes, the buildpack will add a riff-invoker-node key and fn metadata extracted from the riff metadata.
If several languages are detected simultaneously, the detect phase errors out.
The override key in riff.toml can be used to bypass detection and force the use of a particular invoker.
If a node function has been detected
- Contributes the riff Node Invoker to a launch layer, set as the main
nodeentry point withFUNCTION_URI = <artifact>set as an environment variable. Note thatartifactmay actually be empty, in which case the invoker willrequire()the current directory (the function), which in turn expects that it contains a validpackage.jsonfile with itsmainentry point set.
The function behavior is exposed via standard buildpack process types:
- Contributes
webprocess - Contributes
functionprocess
The buildpack optionally accepts the following bindings during the build phase:
| Key | Value | Description |
|---|---|---|
<dependency-digest> |
<uri> |
If needed, the buildpack will fetch the dependency with digest <dependency-digest> from <uri> |
To build the node-function-buildpack you'll need
- Go 1.13+
- to run acceptance tests:
- a running local docker daemon
- for local function builds
- the
packcommand line tool
- the
You can build the buildpack by running
makeThis will package (with pre-downloaded cache layers) the buildpack in the
artifactory/io/projectriff/node/io.projectriff.node/latest directory. That can be used as a uri in a builder.toml
file of a builder (see https://github.com/projectriff/builder)
This buildpack is released under version 2.0 of the Apache License.