Automate SBOM generation for all CI images#309
Automate SBOM generation for all CI images#309jayavenkatesh19 wants to merge 9 commits intorapidsai:mainfrom
Conversation
jameslamb
left a comment
There was a problem hiding this comment.
Doing this in a multi-stage build makes sense to me!
I left some suggestions on standardizing things and make the configuration flow a little stricter.
ci-conda.Dockerfile
Outdated
| ARG BUILDPLATFORM | ||
| ARG SYFT_VER | ||
|
|
||
| RUN apk add --no-cache curl tar ca-certificates \ |
There was a problem hiding this comment.
Since this is repeated in multiple places, would you consider moving it into a script that's mounted in at build time?
Like this: rapidsai/docker#840
ci-conda.Dockerfile
Outdated
| ################################ build the syft-base image ############################### | ||
|
|
||
| FROM --platform=$BUILDPLATFORM alpine:3.20 AS syft-base | ||
| ARG BUILDPLATFORM |
There was a problem hiding this comment.
I was confused not to see changes in the CI workflows to ensure this is passed in, but now I see... it's defined in the build environment by default: https://docs.docker.com/build/building/multi-platform/#cross-compilation
Just sharing for the benefit of other reviewers.
ci-conda.Dockerfile
Outdated
| ARG SYFT_VER=1.32.0 | ||
|
|
||
| ################################ build the syft-base image ############################### | ||
|
|
||
| FROM --platform=$BUILDPLATFORM alpine:3.20 AS syft-base |
There was a problem hiding this comment.
| ARG SYFT_VER=1.32.0 | |
| ################################ build the syft-base image ############################### | |
| FROM --platform=$BUILDPLATFORM alpine:3.20 AS syft-base | |
| ARG SYSFT_ALPINE_VER=notset | |
| ARG SYFT_VER=notset | |
| ################################ build the syft-base image ############################### | |
| FROM --platform=$BUILDPLATFORM alpine:${SYFT_ALPINE_VER} AS syft-base |
Let's put the Alpine version and SYFT_VER in versions.yaml instead: https://github.com/rapidsai/ci-imgs/blob/main/versions.yaml. And let's please avoid putting any hard-coded versions into ARG statements and instead using notset (to give us a chance to catch bugs like "did not successfully pass configuration through).
- keeps it consistent across images
- allows us to use renovate to easily auto-update it
ci-conda.Dockerfile
Outdated
| EOF | ||
|
|
||
| FROM miniforge-cuda | ||
| # Generate SBOM for the miniforge-cuda stage |
There was a problem hiding this comment.
We recently removed miniforge-cuda and 26.02 will be the final release where it's published: #345
We only need to generate SBOMs for ci-conda, ci-wheel, and ci-testwheel.
citestwheel.Dockerfile
Outdated
| COPY pip.conf /etc/xdg/pip/pip.conf | ||
|
|
||
| # Generate SBOM for the citestwheel image | ||
| FROM syft-base AS citestwheel-sbom |
There was a problem hiding this comment.
| FROM syft-base AS citestwheel-sbom | |
| FROM syft-base AS sbom |
I don't think it's necessary to add citestwheel- and similar prefixes to these stage names. They're already self-contained within 1 Dockerfile.
I recommend standardizing all of them to something generic.
citestwheel.Dockerfile
Outdated
| mkdir -p /out && \ | ||
| syft scan \ | ||
| --source-name "rapidsai/citestwheel" \ | ||
| --scope all-layers \ | ||
| --output cyclonedx-json@1.6=/out/sbom.json \ | ||
| dir:/rootfs |
There was a problem hiding this comment.
The only thing that seems to differ in this call across the dockerfiles is --source-name, and I'm guessing we'd want the other configuration for syft to otherwise be consistent across all images.
Could you move this into a script that's mounted in at build time, similar to rapidsai/docker#840?
The --source-name could be provided by a new build argument IMAGE_REPO or similar, we already have enough information about that in the GitHub Actions configs to thread that through:
b96bc4c to
ff0f4fd
Compare
ff0f4fd to
7d3bf0b
Compare
Towards https://github.com/rapidsai/build-infra/issues/280
Current Approach
PR builds
rapidsai/stagingon DockerhubGITHUB_REFBranch push
rapidsai/<image_repo>on DockerhubProposed changes using the multi-stage build approach
syft-basewith the Syft binary installed on a minimal alpine 3.20 image.<ci-img>-baseto differentiate it from the final image.<ci-img>-sbomwhere the built stage is mounted to a specified location on thesyft-basestagesyft-scanis done on the mounted location, and an SBOM is generated.