Skip to content

Commit 5ff9946

Browse files
vtaskowtyndria
andauthored
ci(images): Add sbom to docker builds for licensing reasons (#7068)
* Add sbom to docker builds * Fix makefile buildx commands, tested manually * add `docker-build-and-push-prod` command for `alibi-explain-server` * add `docker-build-and-push-prod` for `alibi-detect-server` * add commands for xgboostserver to build and push image with SBOM * Enable `images` workflow to test from non-master branch * Fix pushing python wrapper image with SBOM * Attempt to fix a digest error when pulling the wrapper image in the prepackaged servers job * fix jq command for fetching the wrapper digest * Add step `Force docker to use the docker-container driver` to the `prepackaged-components` job * Fix building alibi-detect-server (sdk wasn't copied) * Try to use `docker/setup-buildx-action` with `driver` arg to use docker-container * Optimising more space for alibi-detect-server image * Add necessary commands to attach SBOM for mlflowserver, sklearnserver and tfserving_proxy * Move models images push to the separate job * Revert "Move models images push to the separate job" This reverts commit 74b3787. * Ensure models are pushed as paart of the prepackaged-components job * Revert original triggers for the `images` workflow --------- Co-authored-by: Antanina Vertsinskaya <[email protected]>
1 parent 36d14d9 commit 5ff9946

File tree

18 files changed

+128
-14
lines changed

18 files changed

+128
-14
lines changed

.github/workflows/images.yml

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525

2626
- name: Set up Docker Buildx
2727
uses: docker/setup-buildx-action@v3
28+
with:
29+
driver: docker-container
30+
cleanup: true
2831

2932
- name: Login to DockerHub
3033
uses: docker/login-action@v3
@@ -38,20 +41,22 @@ jobs:
3841
USER_INPUT="${{ github.event.inputs.docker-tag }}"
3942
echo "value=${USER_INPUT:-latest}" >> $GITHUB_OUTPUT
4043
41-
4244
- name: Build and push
4345
working-directory: ./operator/
4446
env:
4547
VERSION: ${{ steps.docker-tag.outputs.value }}
4648
run: |
47-
make docker-build docker-push
49+
make docker-build-and-push-prod
4850
4951
executor:
5052
runs-on: ubuntu-latest
5153
steps:
5254
- uses: actions/checkout@v4
5355
- name: Set up Docker Buildx
5456
uses: docker/setup-buildx-action@v3
57+
with:
58+
driver: docker-container
59+
cleanup: true
5560

5661
- name: Login to DockerHub
5762
uses: docker/login-action@v3
@@ -70,7 +75,7 @@ jobs:
7075
env:
7176
VERSION: ${{ steps.docker-tag.outputs.value }}
7277
run: |
73-
make docker-build docker-push
78+
make docker-build-and-push-prod
7479
7580
rclone-storage-initializer:
7681
runs-on: ubuntu-latest
@@ -90,12 +95,18 @@ jobs:
9095
USER_INPUT="${{ github.event.inputs.docker-tag }}"
9196
echo "value=${USER_INPUT:-latest}" >> $GITHUB_OUTPUT
9297
98+
- name: Set up Docker Buildx
99+
uses: docker/setup-buildx-action@v3
100+
with:
101+
driver: docker-container
102+
cleanup: true
103+
93104
- name: Build and push (Rclone Storage Initializer)
94105
working-directory: ./components/rclone-storage-initializer
95106
env:
96107
VERSION: ${{ steps.docker-tag.outputs.value }}
97108
run: |
98-
make docker-build docker-push
109+
make docker-build-and-push-prod
99110
100111
s2i-wrapper:
101112
runs-on: ubuntu-latest
@@ -105,6 +116,9 @@ jobs:
105116

106117
- name: Set up Docker Buildx
107118
uses: docker/setup-buildx-action@v3
119+
with:
120+
driver: docker-container
121+
cleanup: true
108122

109123
- name: Login to DockerHub
110124
uses: docker/login-action@v3
@@ -123,22 +137,25 @@ jobs:
123137
env:
124138
VERSION: ${{ steps.docker-tag.outputs.value }}
125139
run: |
126-
make docker-build-conda-base docker-push-conda-base
140+
make docker-build-and-push-prod-conda-base
127141
128142
- name: Build and push (Base Wrapper)
129143
working-directory: ./wrappers/s2i/python
130144
env:
131145
VERSION: ${{ steps.docker-tag.outputs.value }}
132146
run: |
133-
make docker-build docker-push PYTHON_VERSION=3.12.12
134-
make docker-tag-base-python docker-push-base-python PYTHON_VERSION=3.12.12
135-
docker save -o /tmp/base-wrapper.tar seldonio/seldon-core-s2i-python312:${VERSION}
147+
make docker-build-and-push-prod PYTHON_VERSION=3.12.12
148+
make docker-tag-and-push-prod-default
149+
150+
docker buildx imagetools inspect \
151+
seldonio/seldon-core-s2i-python312:${VERSION} \
152+
--format '{{json .}}' > /tmp/base-wrapper.json
136153
137154
- name: Upload artifact
138155
uses: actions/upload-artifact@v4
139156
with:
140157
name: base-wrapper
141-
path: /tmp/base-wrapper.tar
158+
path: /tmp/base-wrapper.json
142159

143160
prepackaged-components:
144161
runs-on: ubuntu-latest
@@ -159,11 +176,14 @@ jobs:
159176
- name: Checkout Git Commit
160177
uses: actions/checkout@v4
161178

162-
- name: Free up disk space (android, haskell, dotnet)
179+
- name: Free up disk space (android, haskell, dotnet, toolchains, caches)
163180
run: |
164181
sudo rm -rf /usr/local/lib/android || true
165182
sudo rm -rf /opt/ghc || true
166183
sudo rm -rf /usr/share/dotnet || true
184+
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
185+
sudo rm -rf /opt/hostedtoolcache || true
186+
sudo rm -rf /home/runner/.cache/pip || true
167187
df -h
168188
169189
- name: Login to DockerHub
@@ -191,16 +211,28 @@ jobs:
191211
name: base-wrapper
192212
path: /tmp
193213

194-
- name: Load image
214+
- name: Extract image digest and pull
195215
run: |
196-
docker load --input /tmp/base-wrapper.tar
216+
DIGEST=$(jq -r '.manifest.digest' /tmp/base-wrapper.json)
217+
IMAGE_REF="seldonio/seldon-core-s2i-python312@${DIGEST}"
218+
219+
docker pull "${IMAGE_REF}"
197220

198221
- name: Remove tarball
199-
run: rm -f /tmp/base-wrapper.tar
222+
run: rm -f /tmp/base-wrapper.json
223+
224+
- name: Remove base-wrapper artifact directory
225+
run: rm -rf /tmp/base-wrapper || true
226+
227+
- name: Set up Docker Buildx
228+
uses: docker/setup-buildx-action@v3
229+
with:
230+
driver: docker-container
231+
cleanup: true
200232

201233
- name: Build and push (Prepackaged Server Image)
202234
working-directory: ./${{ matrix.server }}/
203235
env:
204236
VERSION: ${{ steps.docker-tag.outputs.value }}
205237
run: |
206-
make docker-build docker-push
238+
make docker-build-and-push-prod

components/alibi-detect-server/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ curl-metrics-server-get:
9595
docker-build: get_local_repo
9696
docker build --platform linux/amd64 -f Dockerfile --build-arg BASE_IMAGE=${BASE_IMAGE} --build-arg VERSION=${VERSION} -t ${IMAGE}:${VERSION} .
9797

98+
docker-build-and-push-prod: get_local_repo
99+
docker buildx build --provenance=true --attest type=sbom,generator=docker/scout-sbom-indexer:latest --platform linux/amd64 -f Dockerfile --build-arg BASE_IMAGE=${BASE_IMAGE} --build-arg VERSION=${VERSION} -t ${IMAGE}:${VERSION} . --push
100+
98101
docker-push:
99102
docker push ${IMAGE}:${VERSION}
100103

components/alibi-explain-server/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ docker-build:
5151
docker-push:
5252
docker push ${IMAGE}:${VERSION}
5353

54+
docker-build-and-push-prod:
55+
docker buildx build --provenance=true --attest type=sbom,generator=docker/scout-sbom-indexer:latest --platform linux/amd64 -f Dockerfile --build-arg BASE_IMAGE=${BASE_IMAGE} --build-arg VERSION=${VERSION} -t ${IMAGE}:${VERSION} . --push
56+
5457
kind_load: docker-build
5558
kind load docker-image ${IMAGE}:${VERSION} --name ${KIND_NAME}
5659

components/rclone-storage-initializer/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ IMAGE_TAG = ${DOCKER_REGISTRY}/${IMAGE}:${VERSION}
1010
docker-build:
1111
docker build --file=Dockerfile --force-rm=true -t ${IMAGE_TAG} .
1212

13+
docker-build-and-push-prod:
14+
docker buildx build --file=Dockerfile --force-rm=true -t ${IMAGE_TAG} . --provenance=true --attest type=sbom,generator=docker/scout-sbom-indexer:latest --push
15+
1316
docker-push:
1417
docker push ${DOCKER_REGISTRY}/${IMAGE}:${VERSION}
1518

components/routers/epsilon-greedy/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ docker-build:
88
docker-push:
99
docker push $(IMAGE_NAME):$(VERSION)
1010

11+
docker-build-and-push-prod: docker-build docker-push
12+
1113
kind_load: docker-build
1214
kind load -v 3 docker-image ${IMAGE_NAME}:${VERSION} --name ${KIND_NAME}

examples/models/mean_classifier/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ docker-build:
1212
docker-push:
1313
docker push ${IMAGE_BASE}:${VERSION}
1414

15+
docker-build-and-push-prod: docker-build docker-push
16+
1517
run_local:
1618
export PREDICTIVE_UNIT_HTTP_SERVICE_PORT=9001 && export PREDICTIVE_UNIT_GRPC_SERVICE_PORT=5001 && export TRACING=1 && export JAEGER_AGENT_HOST=localhost && export JAEGER_AGENT_PORT=6831 && export JAEGER_SAMPLER_TYPE=const && export JAEGER_SAMPLER_PARAM=1 && export SELDON_DEBUG=0 && seldon-core-microservice --service-type MODEL MeanClassifier
1719

executor/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ docker-build: copy_operator copy_openapi_resources
9797
docker-push:
9898
docker push ${SELDON_EXECUTOR_IMG}
9999

100+
docker-build-and-push-prod: copy_operator copy_openapi_resources
101+
docker buildx build -f Dockerfile.executor -t ${SELDON_EXECUTOR_IMG} . --provenance=true --attest type=sbom,generator=docker/scout-sbom-indexer:latest --push
102+
100103

101104
# Red Hat Related
102105

operator/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ docker-build: generate-resources
177177
docker-push:
178178
docker push ${SELDON_OPERATOR_IMG}
179179

180+
docker-build-and-push-prod: generate-resources
181+
docker buildx build . -t ${SELDON_OPERATOR_IMG} --provenance=true --attest type=sbom,generator=docker/scout-sbom-indexer:latest --push
182+
180183
# Installing Images in Kind CLusters
181184
kind-image-install: docker-build
182185
kind load -v 3 docker-image ${SELDON_OPERATOR_IMG} --name ${KIND_NAME}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ARG BASE_IMAGE
2+
ARG BASE_TAG
3+
FROM ${BASE_IMAGE}:${BASE_TAG}

servers/mlflowserver/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ DOCKER_REGISTRY ?= seldonio
55

66
IMAGE_NAME_BASE = mlflowserver
77
IMAGE_NAME = ${DOCKER_REGISTRY}/${IMAGE_NAME_BASE}
8+
IMAGE_NAME_PROD_BASE=${IMAGE_NAME}-prod-base
89
KIND_NAME ?= kind
910

1011
BASE_IMAGE = ${DOCKER_REGISTRY}/seldon-core-s2i-python312:${VERSION}
@@ -19,6 +20,15 @@ docker-build:
1920
docker-push:
2021
docker push ${IMAGE_NAME}:${VERSION}
2122

23+
# Build and push s2i base image to the private repository in dockerhub
24+
# After it's used as a base image for building the final image with SBOM attached
25+
docker-push-prod-base: docker-build
26+
docker tag ${IMAGE_NAME}:${VERSION} ${IMAGE_NAME_PROD_BASE}:${VERSION}
27+
docker push ${IMAGE_NAME_PROD_BASE}:${VERSION}
28+
29+
docker-build-and-push-prod: docker-push-prod-base
30+
docker buildx build --provenance=true --attest type=sbom,generator=docker/scout-sbom-indexer:latest -f Dockerfile.s2i --build-arg BASE_IMAGE=${IMAGE_NAME_PROD_BASE} --build-arg BASE_TAG=${VERSION} -t ${IMAGE_NAME}:${VERSION} . --push
31+
2232
kind-load: docker-build
2333
kind load -v 3 docker-image ${IMAGE_NAME}:${VERSION} --name ${KIND_NAME}
2434

0 commit comments

Comments
 (0)