Skip to content

Commit a3a0c4e

Browse files
authored
Merge pull request #11 from lf-edge/doc-sbom-deps
document sbom requirements
2 parents e2d300a + ef31e95 commit a3a0c4e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,34 @@ RUN cargo build --release
6363
RUN cargo sbom > sbom.spdx.json
6464
```
6565

66+
## SBoM
67+
68+
All EVE packages **must** have an SBoM. When the packages are built using `linuxkit pkg build`, which
69+
itself calls buildkit, the SBoM is automatically generated and included in the package. It only scans the
70+
final stage of the image. In the case of rust-generated binaries, the final binary does **not**
71+
contain any information about dependencies, so the SBoM must be generated manually.
72+
73+
When building a package, you must:
74+
75+
1. Generate the sbom using `cargo sbom > sbom.spdx.json`
76+
1. Copy the `sbom.spdx.json` into the final image
77+
78+
Hence, the following are **mandatory** stages:
79+
80+
```Dockerfile
81+
# in the build stage FROM eve-rust, before or after `cargo build`
82+
RUN cargo sbom > target/sbom.spdx.json
83+
84+
# in the final FROM scratch stage
85+
COPY --from=rust /src/foo/target/sbom.spdx.json /sbom.spdx.json
86+
```
87+
88+
The above will go away when the sbom generation is a built-in part of cargo,
89+
to be enabled by configuration. See [this RFC](https://github.com/rust-lang/rfcs/pull/3553).
90+
91+
92+
## Cross-compilation
93+
6694
To enable cross-compilation we need few extra steps. By default cargo builds for host platform so the target must be specified explicitly either using `--target <target>` or by setting `CARGO_BUILD_TARGET` environment variable. See [Cargo docs](https://doc.rust-lang.org/cargo/reference/environment-variables.html?highlight=CARGO_BUILD_TARGET#configuration-environment-variables)
6795

6896
```Dockerfile

0 commit comments

Comments
 (0)