-
Notifications
You must be signed in to change notification settings - Fork 55
Automate SBOM generation for container images #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jayavenkatesh19
wants to merge
9
commits into
rapidsai:main
Choose a base branch
from
jayavenkatesh19:sbom-generation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
efbf8c6
added SBOM generation
jayavenkatesh19 2bed04b
added source for syft scan
jayavenkatesh19 537db9f
added comments
jayavenkatesh19 0309c43
Merge branch 'rapidsai:main' into sbom-generation
jayavenkatesh19 dc7fa65
added ignore for halolint
jayavenkatesh19 3ee4ccb
updated bash to sh to match alpine
jayavenkatesh19 b8d7230
update to /bin/ash to pass hadolint check
jayavenkatesh19 f846f33
Merge branch 'main' into sbom-generation
jayavenkatesh19 0776571
fixed SBOM source error
jayavenkatesh19 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,24 @@ ARG LINUX_DISTRO_VER=22.04 | |
| ARG LINUX_VER=${LINUX_DISTRO}${LINUX_DISTRO_VER} | ||
|
|
||
| ARG RAPIDS_VER=26.02 | ||
| ARG SYFT_VER=1.32.0 | ||
|
|
||
| # Build syft base image | ||
| FROM --platform=$BUILDPLATFORM alpine:3.20 AS syft-base | ||
| ARG BUILDPLATFORM | ||
| ARG SYFT_VER | ||
|
|
||
| SHELL ["/bin/ash", "-eo", "pipefail", "-c"] | ||
|
|
||
| RUN apk add --no-cache curl tar ca-certificates \ | ||
| && case "$BUILDPLATFORM" in \ | ||
| linux/amd64) SYFT_ARCH="linux_amd64" ;; \ | ||
| linux/arm64) SYFT_ARCH="linux_arm64" ;; \ | ||
| *) echo "Unsupported BUILDPLATFORM: ${BUILDPLATFORM}" && exit 1 ;; \ | ||
| esac \ | ||
| && curl -sSfL "https://github.com/anchore/syft/releases/download/v${SYFT_VER}/syft_${SYFT_VER}_${SYFT_ARCH}.tar.gz" \ | ||
| | tar -xz -C /usr/local/bin syft \ | ||
| && chmod +x /usr/local/bin/syft | ||
|
|
||
| # Gather dependency information | ||
|
|
||
|
|
@@ -40,7 +58,7 @@ EOF | |
|
|
||
|
|
||
| # Base image | ||
| FROM rapidsai/miniforge-cuda:${RAPIDS_VER}-cuda${CUDA_VER}-base-${LINUX_VER}-py${PYTHON_VER} AS base | ||
| FROM rapidsai/miniforge-cuda:${RAPIDS_VER}-cuda${CUDA_VER}-base-${LINUX_VER}-py${PYTHON_VER} AS base-build | ||
| ARG CUDA_VER | ||
| ARG PYTHON_VER | ||
|
|
||
|
|
@@ -99,8 +117,26 @@ ENTRYPOINT ["/home/rapids/entrypoint.sh"] | |
| CMD ["ipython"] | ||
|
|
||
|
|
||
| # SBOM generation for base image | ||
| FROM syft-base AS base-sbom | ||
| SHELL ["/bin/sh", "-euo", "pipefail", "-c"] | ||
|
|
||
| RUN --mount=type=bind,from=base-build,source=/,target=/rootfs,ro \ | ||
| mkdir -p /out && \ | ||
| syft scan \ | ||
| --source-name "rapidsai/base" \ | ||
| --scope all-layers \ | ||
| --output [email protected]=/out/sbom.json \ | ||
| dir:/rootfs | ||
|
|
||
| # Create the base image with the SBOM | ||
| FROM base-build AS base | ||
| COPY --from=base-sbom /out/sbom.json /sbom/sbom.json | ||
| USER rapids | ||
|
|
||
|
|
||
| # Notebooks image | ||
| FROM base AS notebooks | ||
| FROM base AS notebooks-build | ||
|
|
||
| ARG CUDA_VER | ||
| ARG LINUX_DISTRO | ||
|
|
@@ -174,3 +210,20 @@ LABEL com.nvidia.workbench.schema-version="v2" | |
| LABEL com.nvidia.workbench.user.gid="1000" | ||
| LABEL com.nvidia.workbench.user.uid="1001" | ||
| LABEL com.nvidia.workbench.user.username="rapids" | ||
|
|
||
| # SBOM generation for notebooks image | ||
| FROM syft-base AS notebooks-sbom | ||
| SHELL ["/bin/sh", "-euo", "pipefail", "-c"] | ||
|
|
||
| RUN --mount=type=bind,from=notebooks-build,source=/,target=/rootfs,ro \ | ||
| mkdir -p /out && \ | ||
| syft scan \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to rapidsai/ci-imgs#309 (comment), I think this should be moved to a mounted-in script so we only have to set the |
||
| --source-name "rapidsai/notebooks" \ | ||
| --scope all-layers \ | ||
| --output [email protected]=/out/sbom.json \ | ||
| dir:/rootfs | ||
|
|
||
| # Create the notebooks image with the SBOM | ||
| FROM notebooks-build AS notebooks | ||
| COPY --from=notebooks-sbom /out/sbom.json /sbom/sbom.json | ||
| USER rapids | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to rapidsai/ci-imgs#309 (comment), could you please move the
syftversion and Alpine tag intoversions.yaml?To be fair, there wasn't a
versions.yamlwhen you started this PR, it was only very recently added: #834