99
99
stepTemplate :
100
100
env :
101
101
- name : BUILDER_IMAGE
102
- value : " quay.io/redhat-user-workloads/konflux-build-pipeli-tenant/paketo-container:ea8ddb8818bb4a55546927e7674b0362dabd6342 "
102
+ value : " quay.io/redhat-user-workloads/konflux-build-pipeli-tenant/paketo-container:2a51208449696d85b2f80444bee7bf7caa104f48 "
103
103
- name : CONTEXT
104
104
value : $(params.CONTEXT)
105
105
- name : HERMETIC
@@ -129,7 +129,7 @@ spec:
129
129
- $(params.CACHI2_ARTIFACT)=/var/workdir/cachi2
130
130
- args :
131
131
- " $(params.BUILD_ARGS[*])"
132
- image : " quay.io/konflux-ci/buildah-task:latest"
132
+ image : quay.io/konflux-ci/buildah-task:latest@sha256:b2d6c32d1e05e91920cd4475b2761d58bb7ee11ad5dff3ecb59831c7572b4d0c
133
133
name : " run-script"
134
134
script : |-
135
135
#!/usr/bin/env bash
@@ -216,9 +216,27 @@ spec:
216
216
unshare -Uf "${UNSHARE_ARGS[@]}" --keep-caps -r --map-users 1,1,65536 --map-groups 1,1,65536 -w source -- \
217
217
pack builder create ${IMAGE} --config builder.toml ${PACK_ARGS}
218
218
219
- BASE_IMAGE=$(tomljson source/builder.toml | jq '.stack."build-image"')
219
+ BASE_IMAGE=$(tomljson source/builder.toml | jq -r '.stack."build-image"')
220
220
podman inspect ${BASE_IMAGE} | jq -r '.[].Digest' > /shared/BASE_IMAGES_DIGESTS
221
- echo "$BASE_IMAGE" >/shared/base_images_from_dockerfile
221
+
222
+ echo "Create locally a Dockerfile using the build image defined part of the builder.toml file to include the BASE IMAGE"
223
+ dockerfile_path=$(mktemp --suffix=-Dockerfile)
224
+ cat <<EOF > $dockerfile_path
225
+ FROM $BASE_IMAGE
226
+ EOF
227
+
228
+ dockerfile-json "$dockerfile_path" >/shared/parsed_dockerfile.json
229
+
230
+ BASE_IMAGES=$(
231
+ jq -r '.Stages[] | select(.From | .Stage or .Scratch | not) | .BaseName | select(test("^oci-archive:") | not)' /shared/parsed_dockerfile.json
232
+ )
233
+
234
+ if [ "${HERMETIC}" == "true" ]; then
235
+ for image in $BASE_IMAGES; do
236
+ echo "Pull the base image: $image using unshare"
237
+ unshare -Ufp --keep-caps -r --map-users 1,1,65536 --map-groups 1,1,65536 -- buildah pull $image
238
+ done
239
+ fi
222
240
223
241
REMOTESSHEOF
224
242
chmod +x scripts/script-build.sh
@@ -239,7 +257,6 @@ spec:
239
257
REMOTESSHEOF
240
258
chmod +x scripts/script-post-build.sh
241
259
242
-
243
260
echo "Step 3 :: Execute the bash script on the VM"
244
261
245
262
rsync -ra scripts "$SSH_HOST:$BUILD_DIR"
@@ -335,7 +352,6 @@ spec:
335
352
export IMAGE
336
353
fi
337
354
338
-
339
355
echo "Merging contents of sbom-source.json and sbom-image.json into sbom-cyclonedx.json"
340
356
python3 /scripts/merge_syft_sboms.py
341
357
@@ -345,13 +361,10 @@ spec:
345
361
mv sbom-temp.json sbom-cyclonedx.json
346
362
fi
347
363
348
- echo "Creating sbom-purl.json"
349
- python3 /scripts/create_purl_sbom.py
350
-
351
364
echo "Adding base images data to sbom-cyclonedx.json"
352
365
python3 /scripts/base_images_sbom_script.py \
353
366
--sbom=sbom-cyclonedx.json \
354
- --base-images-from- dockerfile=/shared/base_images_from_dockerfile \
367
+ --parsed- dockerfile=/shared/parsed_dockerfile.json \
355
368
--base-images-digests=/shared/BASE_IMAGES_DIGESTS
356
369
securityContext :
357
370
runAsUser : 0
@@ -383,16 +396,13 @@ spec:
383
396
update-ca-trust
384
397
fi
385
398
386
-
387
399
echo "Pull the image from the OCI storage."
388
-
389
400
buildah --storage-driver "$STORAGE_DRIVER" pull "$IMAGE"
390
401
391
-
392
402
echo "Copy within the container of the image the sbom files"
393
403
394
404
container=$(buildah --storage-driver "$STORAGE_DRIVER" from --pull-never "$IMAGE")
395
- buildah --storage-driver "$STORAGE_DRIVER" copy "$container" sbom-cyclonedx.json sbom-purl.json /root/buildinfo/content_manifests/
405
+ buildah --storage-driver "$STORAGE_DRIVER" copy "$container" sbom-cyclonedx.json /root/buildinfo/content_manifests/
396
406
397
407
BUILDAH_ARGS=()
398
408
if [ "${SQUASH}" == "true" ]; then
@@ -401,7 +411,6 @@ spec:
401
411
402
412
buildah --storage-driver "$STORAGE_DRIVER" commit "${BUILDAH_ARGS[@]}" "$container" "$IMAGE"
403
413
404
-
405
414
echo "Pushing to ${IMAGE%:*}:${TASKRUN_NAME}"
406
415
407
416
retries=5
0 commit comments