Skip to content

Commit 0e7e2d1

Browse files
edmorleyMalax
andauthored
Add nodejs-function-invoker buildpack (#47)
This replaces the various Riff-based invoker buildpacks, now that Riff has been sunset. This buildpack vendors the new Node.js invoker: https://github.com/forcedotcom/sf-fx-runtime-nodejs For Riff invoker buildpack prior art, see: https://github.com/forcedotcom/nodejs-sf-fx-buildpack https://github.com/projectriff/node-function-buildpack Takes inspiration from the JVM invoker buildpack: https://github.com/heroku/buildpacks-jvm/tree/main/buildpacks/jvm-function-invoker ...though has a number of changes since this repo has different buildpack utility functions (eg for logging, downloads), and uses shpec rather than Rapier for testing. This initial version of the buildpack doesn't implement caching, since whilst the invoker is under active development, the release assets will be regularly changing, so using unversioned URLs and frequently changing archive SHA. This buildpack also currently doesn't pass `$PORT` to the entrypoint, since the invoker currently doesn't support it (and may read directly from the env anyway, when there is support for custom ports). The shellcheck version has been bumped to pick up a fix that reduces the number of `source=` annotations required to prevent `SC1090` errors. After this PR is merged and the buildpack published, the meta-buildpack `nodejs-function` will be updated in another PR, to reference this buildpack instead of the Riff-based buildpacks. Closes GUS-W-9115013. Co-authored-by: Manuel Fuchs <[email protected]>
1 parent 46dec4f commit 0e7e2d1

File tree

19 files changed

+357
-5
lines changed

19 files changed

+357
-5
lines changed

.circleci/config.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ orbs:
44
pack: buildpacks/[email protected]
55
heroku-buildpacks:
66
commands:
7-
install-build-dependencies:
7+
install-yq:
88
steps:
9-
- run:
10-
name: "Install rsync, jq via apt"
11-
command: sudo apt-get update && sudo apt-get install -y rsync jq
129
- run:
1310
name: "Install yj 5.0.0"
1411
command: |
@@ -17,6 +14,12 @@ orbs:
1714
chmod +x "${bin_dir}/yj"
1815
1916
echo "export PATH=\"${bin_dir}:\${PATH}\"" >> $BASH_ENV
17+
install-build-dependencies:
18+
steps:
19+
- run:
20+
name: "Install rsync, jq via apt"
21+
command: sudo apt-get update && sudo apt-get install -y rsync jq
22+
- install-yq
2023

2124
jobs:
2225
package-buildpack:
@@ -49,7 +52,7 @@ jobs:
4952
5053
shell-linting:
5154
docker:
52-
- image: koalaman/shellcheck-alpine:v0.7.1
55+
- image: koalaman/shellcheck-alpine:v0.7.2
5356
steps:
5457
- run: "apk add git"
5558
# shfmt is currently (Jan 2021) only available in the edge community repository.
@@ -75,6 +78,8 @@ jobs:
7578
- checkout
7679
- setup_remote_docker:
7780
docker_layer_caching: true
81+
# Required so that yq is available for buildpacks that depend upon the nodejs-engine's copy of yq.
82+
- heroku-buildpacks/install-yq
7883
- run:
7984
name: Shpec unit tests on <<parameters.stack>>
8085
command: shpec << parameters.buildpack-dir >>/shpec/*_shpec.sh
@@ -89,6 +94,7 @@ workflows:
8994
parameters:
9095
buildpack-dir:
9196
- "buildpacks/nodejs"
97+
- "buildpacks/nodejs-function-invoker"
9298
- "buildpacks/npm"
9399
- "buildpacks/typescript"
94100
stack:
@@ -101,6 +107,7 @@ workflows:
101107
parameters:
102108
buildpack-dir:
103109
- "buildpacks/nodejs"
110+
- "buildpacks/nodejs-function-invoker"
104111
- "buildpacks/npm"
105112
- "buildpacks/typescript"
106113
- "meta-buildpacks/nodejs"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4+
5+
## [Unreleased]
6+
### Added
7+
- Initial implementation ([#47](https://github.com/heroku/buildpacks-node/pull/47))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Node.js Function Invoker Cloud Native Buildpack
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
# shellcheck source-path=SCRIPTDIR/..
3+
4+
set -euo pipefail
5+
6+
layers_dir="${1:?}"
7+
8+
source "${CNB_BUILDPACK_DIR}/lib/build.sh"
9+
10+
install_runtime "${layers_dir}"
11+
write_launch_toml "${layers_dir}" "$(pwd)"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
# shellcheck source-path=SCRIPTDIR/..
3+
4+
set -euo pipefail
5+
6+
app_dir=$(pwd)
7+
build_plan="${2:?}"
8+
9+
source "${CNB_BUILDPACK_DIR}/lib/detect.sh"
10+
11+
if detect_function_app "${app_dir}"; then
12+
write_to_build_plan "${build_plan}"
13+
exit 0
14+
fi
15+
16+
exit 100
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
api = "0.6"
2+
3+
[buildpack]
4+
id = "heroku/nodejs-function-invoker"
5+
version = "0.1.0"
6+
name = "Node.js Function Invoker"
7+
clear-env = true
8+
homepage = "https://github.com/heroku/buildpacks-nodejs"
9+
keywords = ["nodejs", "node", "javascript", "function"]
10+
11+
[[licenses]]
12+
type = "MIT"
13+
14+
[[stacks]]
15+
id = "heroku-18"
16+
17+
[[stacks]]
18+
id = "heroku-20"
19+
20+
[[stacks]]
21+
id = "io.buildpacks.stacks.bionic"
22+
23+
[metadata]
24+
25+
[metadata.runtime]
26+
url = "https://sf-fx-nodejs-internal-early-access.s3.us-east-2.amazonaws.com/sf-fx-runtime-nodejs-0.1.0-ea.tgz"
27+
28+
[metadata.release]
29+
30+
[metadata.release.docker]
31+
repository = "public.ecr.aws/heroku-buildpacks/heroku-nodejs-function-invoker-buildpack"

buildpacks/nodejs-function-invoker/fixtures/function-toml/function.toml

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

buildpacks/nodejs-function-invoker/fixtures/package-json-only/package.json

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)