You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplify the buildpack author guide, using NodeJS instead of Ruby.
The switch to NodeJS makes multi-arch demos more striaghtforward
Signed-off-by: Aidan Delaney <[email protected]>
Copy file name to clipboardExpand all lines: content/docs/buildpack-author-guide/create-buildpack/adding-bill-of-materials.md
+50-92Lines changed: 50 additions & 92 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ You can find some of this information using `pack` via its `inspect-image` comma
17
17
18
18
<!-- test:exec -->
19
19
```bash
20
-
pack inspect-image test-ruby-app
20
+
pack inspect-image test-node-js-app
21
21
```
22
22
<!--+- "{{execute}}"+-->
23
23
You should see the following:
@@ -30,28 +30,27 @@ Run Images:
30
30
31
31
Buildpacks:
32
32
ID VERSION HOMEPAGE
33
-
examples/ruby 0.0.1 -
33
+
examples/node-js 0.0.1 -
34
34
35
35
Processes:
36
36
TYPE SHELL COMMAND ARGS WORK DIR
37
-
web (default) bash bundle exec ruby app.rb /workspace
38
-
worker bash bundle exec ruby worker.rb /workspace
37
+
web (default) bash node-js app.js /workspace
39
38
```
40
39
41
-
Apart from the above standard metadata, buildpacks can also populate information about the dependencies they have provided in form of a `Bill-of-Materials`. Let's see how we can use this to populate information about the version of `ruby` that was installed in the output app image.
40
+
Apart from the above standard metadata, buildpacks can also populate information about the dependencies they have provided in form of a `Bill-of-Materials`. Let's see how we can use this to populate information about the version of `node-js` that was installed in the output app image.
42
41
43
-
To add the `ruby` version to the output of `pack download sbom`, we will have to provide a [Software `Bill-of-Materials`](https://en.wikipedia.org/wiki/Software_bill_of_materials) (`SBOM`) containing this information. There are three "standard" ways to report SBOM data. You'll need to choose to use one of [CycloneDX](https://cyclonedx.org/), [SPDX](https://spdx.dev/) or [Syft](https://github.com/anchore/syft) update the `ruby.sbom.<ext>` (where `<ext>` is the extension appropriate for your SBOM standard, one of `cdx.json`, `spdx.json` or `syft.json`) at the end of your `build` script. Discussion of which SBOM format to choose is outside the scope of this tutorial, but we will note that the SBOM format you choose to use is likely to be the output format of any SBOM scanner (eg: [`syft cli`](https://github.com/anchore/syft)) you might choose to use. In this example we will use the CycloneDX json format.
42
+
To add the `node-js` version to the output of `pack download sbom`, we will have to provide a [Software `Bill-of-Materials`](https://en.wikipedia.org/wiki/Software_bill_of_materials) (`SBOM`) containing this information. There are three "standard" ways to report SBOM data. You'll need to choose to use one of [CycloneDX](https://cyclonedx.org/), [SPDX](https://spdx.dev/) or [Syft](https://github.com/anchore/syft) update the `node-js.sbom.<ext>` (where `<ext>` is the extension appropriate for your SBOM standard, one of `cdx.json`, `spdx.json` or `syft.json`) at the end of your `build` script. Discussion of which SBOM format to choose is outside the scope of this tutorial, but we will note that the SBOM format you choose to use is likely to be the output format of any SBOM scanner (eg: [`syft cli`](https://github.com/anchore/syft)) you might choose to use. In this example we will use the CycloneDX json format.
44
43
45
44
First, annotate the `buildpack.toml` to specify that it emits CycloneDX:
@@ -69,177 +68,136 @@ Then, in our buildpack implementation we will generate the necessary SBOM metada
69
68
```bash
70
69
# ...
71
70
72
-
# Append a Bill-of-Materials containing metadata about the provided ruby version
73
-
cat >>"$layersdir/ruby.sbom.cdx.json"<<EOL
71
+
# Append a Bill-of-Materials containing metadata about the provided node-js version
72
+
cat >>"${layersdir}/node-js.sbom.cdx.json"<<EOL
74
73
{
75
74
"bomFormat": "CycloneDX",
76
75
"specVersion": "1.4",
77
76
"version": 1,
78
77
"components": [
79
78
{
80
79
"type": "library",
81
-
"name": "ruby",
82
-
"version": "$ruby_version"
80
+
"name": "node-js",
81
+
"version": "$node-js_version"
83
82
}
84
83
]
85
84
}
86
85
EOL
87
86
```
88
87
89
-
We can also add an SBOM entry for each dependency listed in `Gemfile.lock`. Here we use `jq` to add a new record to the `components` array in `bundler.sbom.cdx.json`:
88
+
We can also add an SBOM entry for each dependency listed in `package.json`. Here we use `jq` to add a new record to the `components` array in `bundler.sbom.cdx.json`:
90
89
91
90
```bash
92
-
crubybom="${layersdir}/ruby.sbom.cdx.json"
93
-
cat >>${rubybom}<<EOL
91
+
cnode-jsbom="${layersdir}/node-js.sbom.cdx.json"
92
+
cat >>${node-jsbom}<<EOL
94
93
{
95
94
"bomFormat": "CycloneDX",
96
95
"specVersion": "1.4",
97
96
"version": 1,
98
97
"components": [
99
98
{
100
99
"type": "library",
101
-
"name": "ruby",
102
-
"version": "$ruby_version"
100
+
"name": "node-js",
101
+
"version": "$node-js_version"
103
102
}
104
103
]
105
104
}
106
105
EOL
107
-
if [[ -fGemfile.lock ]] ;then
106
+
if [[ -fpackage.json ]] ;then
108
107
forgemin$(gem dep -q | grep ^Gem | sed 's/^Gem //')
109
108
do
110
109
version=${gem##*-}
111
110
name=${gem%-${version}}
112
111
DEP=$(jq --arg name "${name}" --arg version "${version}" \
Viewing your bill-of-materials requires extracting (or `download`ing) the bill-of-materials from your local image. This command can take some time to return.
228
186
229
187
<!-- test:exec -->
230
188
```bash
231
-
pack sbom download test-ruby-app
189
+
pack sbom download test-node-js-app
232
190
```
233
191
<!--+- "{{execute}}"+-->
234
192
235
193
The SBOM information is now downloaded to the local file system:
0 commit comments