@@ -5,7 +5,7 @@ metadata:
5
5
spec :
6
6
steps :
7
7
- name : build
8
- image : quay.io/containers/buildah:v1.37.5
8
+ image : quay.io/containers/buildah:v1.38.1
9
9
imagePullPolicy : Always
10
10
workingDir : $(params.shp-source-root)
11
11
securityContext :
21
21
context=
22
22
dockerfile=
23
23
image=
24
- target =
25
- buildArgs =()
24
+ outputDirectory =
25
+ budArgs =()
26
26
inBuildArgs=false
27
27
registriesBlock=""
28
28
inRegistriesBlock=false
@@ -55,12 +55,21 @@ spec:
55
55
inRegistriesSearch=false
56
56
image="$1"
57
57
shift
58
+ elif [ "${arg}" == "--output-directory" ]; then
59
+ inBuildArgs=false
60
+ inRegistriesBlock=false
61
+ inRegistriesInsecure=false
62
+ inRegistriesSearch=false
63
+ outputDirectory="$1"
64
+ shift
58
65
elif [ "${arg}" == "--target" ]; then
59
66
inBuildArgs=false
60
67
inRegistriesBlock=false
61
68
inRegistriesInsecure=false
62
69
inRegistriesSearch=false
63
- target="$1"
70
+ if [ "$1" != "" ]; then
71
+ budArgs+=(--target "$1")
72
+ fi
64
73
shift
65
74
elif [ "${arg}" == "--build-args" ]; then
66
75
inBuildArgs=true
83
92
inRegistriesBlock=false
84
93
inRegistriesInsecure=false
85
94
elif [ "${inBuildArgs}" == "true" ]; then
86
- buildArgs +=(" --build-arg" "${arg}")
95
+ budArgs +=(--build-arg "${arg}")
87
96
elif [ "${inRegistriesBlock}" == "true" ]; then
88
97
registriesBlock="${registriesBlock}'${arg}', "
89
98
elif [ "${inRegistriesInsecure}" == "true" ]; then
@@ -139,7 +148,7 @@ spec:
139
148
# Building the image
140
149
echo "[INFO] Building image ${image}"
141
150
buildah --storage-driver=$(params.storage-driver) \
142
- bud "${buildArgs [@]}" \
151
+ bud "${budArgs [@]}" \
143
152
--registries-conf=/tmp/registries.conf \
144
153
--tag="${image}" \
145
154
--file="${dockerfile}" \
@@ -149,11 +158,13 @@ spec:
149
158
echo "[INFO] Writing image ${image}"
150
159
buildah --storage-driver=$(params.storage-driver) push \
151
160
"${image}" \
152
- "oci:${target }"
161
+ "oci:${outputDirectory }"
153
162
# That's the separator between the shell script and its args
154
163
- --
155
164
- --context
156
165
- $(params.shp-source-context)
166
+ - --output-directory
167
+ - $(params.shp-output-directory)
157
168
- --dockerfile
158
169
- $(params.dockerfile)
159
170
- --image
@@ -167,7 +178,7 @@ spec:
167
178
- --registries-search
168
179
- $(params.registries-search[*])
169
180
- --target
170
- - $(params.shp-output-directory )
181
+ - $(params.target )
171
182
resources :
172
183
limits :
173
184
cpu : " 1"
@@ -203,6 +214,10 @@ spec:
203
214
type : string
204
215
default : " vfs"
205
216
# For details see the "--storage-driver" section of https://github.com/containers/buildah/blob/main/docs/buildah.1.md#options
217
+ - name : target
218
+ description : " Sets the target stage to be built."
219
+ type : string
220
+ default : " "
206
221
securityContext :
207
222
runAsUser : 0
208
223
runAsGroup : 0
@@ -215,7 +230,7 @@ metadata:
215
230
spec :
216
231
steps :
217
232
- name : build-and-push
218
- image : quay.io/containers/buildah:v1.37.5
233
+ image : quay.io/containers/buildah:v1.38.1
219
234
imagePullPolicy : Always
220
235
workingDir : $(params.shp-source-root)
221
236
securityContext :
@@ -233,7 +248,7 @@ spec:
233
248
context=
234
249
dockerfile=
235
250
image=
236
- buildArgs =()
251
+ budArgs =()
237
252
inBuildArgs=false
238
253
registriesBlock=""
239
254
inRegistriesBlock=false
@@ -267,6 +282,15 @@ spec:
267
282
inRegistriesSearch=false
268
283
image="$1"
269
284
shift
285
+ elif [ "${arg}" == "--target" ]; then
286
+ inBuildArgs=false
287
+ inRegistriesBlock=false
288
+ inRegistriesInsecure=false
289
+ inRegistriesSearch=false
290
+ if [ "$1" != "" ]; then
291
+ budArgs+=(--target "$1")
292
+ fi
293
+ shift
270
294
elif [ "${arg}" == "--build-args" ]; then
271
295
inBuildArgs=true
272
296
inRegistriesBlock=false
@@ -288,7 +312,7 @@ spec:
288
312
inRegistriesBlock=false
289
313
inRegistriesInsecure=false
290
314
elif [ "${inBuildArgs}" == "true" ]; then
291
- buildArgs +=(" --build-arg" "${arg}")
315
+ budArgs +=(--build-arg "${arg}")
292
316
elif [ "${inRegistriesBlock}" == "true" ]; then
293
317
registriesBlock="${registriesBlock}'${arg}', "
294
318
elif [ "${inRegistriesInsecure}" == "true" ]; then
@@ -349,7 +373,7 @@ spec:
349
373
# Building the image
350
374
echo "[INFO] Building image ${image}"
351
375
buildah --storage-driver=$(params.storage-driver) \
352
- bud "${buildArgs [@]}" \
376
+ bud "${budArgs [@]}" \
353
377
--registries-conf=/tmp/registries.conf \
354
378
--tag="${image}" \
355
379
--file="${dockerfile}" \
@@ -378,6 +402,8 @@ spec:
378
402
- $(params.registries-insecure[*])
379
403
- --registries-search
380
404
- $(params.registries-search[*])
405
+ - --target
406
+ - $(params.target)
381
407
resources :
382
408
limits :
383
409
cpu : " 1"
@@ -409,10 +435,14 @@ spec:
409
435
type : string
410
436
default : " Dockerfile"
411
437
- name : storage-driver
412
- description : " The storage driver to use, such as 'overlay' or 'vfs'"
438
+ description : " The storage driver to use, such as 'overlay' or 'vfs'. "
413
439
type : string
414
440
default : " vfs"
415
441
# For details see the "--storage-driver" section of https://github.com/containers/buildah/blob/main/docs/buildah.1.md#options
442
+ - name : target
443
+ description : " Sets the target stage to be built."
444
+ type : string
445
+ default : " "
416
446
securityContext :
417
447
runAsUser : 0
418
448
runAsGroup : 0
@@ -425,9 +455,6 @@ metadata:
425
455
annotations :
426
456
# See https://github.com/moby/buildkit/blob/master/docs/rootless.md#about---oci-worker-no-process-sandbox for more information
427
457
container.apparmor.security.beta.kubernetes.io/step-build-and-push : unconfined
428
- # The usage of seccomp annotation will be deprecate in k8s v1.22.0, see
429
- # https://kubernetes.io/docs/tutorials/clusters/seccomp/#create-a-pod-with-a-seccomp-profile-for-syscall-auditing for more information
430
- container.seccomp.security.alpha.kubernetes.io/step-build-and-push : unconfined
431
458
spec :
432
459
parameters :
433
460
- name : build-args
@@ -438,6 +465,10 @@ spec:
438
465
description : " Configure BuildKit's cache usage. Allowed values are 'disabled' and 'registry'. The default is 'registry'."
439
466
type : string
440
467
default : registry
468
+ - name : dockerfile
469
+ description : The path to the Dockerfile to be used for building the image.
470
+ type : string
471
+ default : Dockerfile
441
472
- name : platforms
442
473
description : " Build the image for different platforms. By default, the image is built for the platform used by the FROM image. If that is present for multiple platforms, then it is built for the environment's platform."
443
474
type : array
@@ -446,20 +477,22 @@ spec:
446
477
description : " The secrets to pass to the build. Values must be in the format ID=FILE_CONTENT."
447
478
type : array
448
479
defaults : []
449
- - name : dockerfile
450
- description : The path to the Dockerfile to be used for building the image.
480
+ - name : target
481
+ description : " Sets the target stage to be built. "
451
482
type : string
452
- default : " Dockerfile "
483
+ default : " "
453
484
steps :
454
485
- name : build-and-push
455
- image : moby/buildkit:v0.17 .0-rootless
486
+ image : moby/buildkit:v0.20 .0-rootless
456
487
imagePullPolicy : Always
457
488
securityContext :
458
489
allowPrivilegeEscalation : true
459
490
capabilities :
460
491
add :
461
492
- SETGID
462
493
- SETUID
494
+ seccompProfile :
495
+ type : Unconfined
463
496
workingDir : $(params.shp-source-root)
464
497
env :
465
498
- name : DOCKER_CONFIG
@@ -481,6 +514,8 @@ spec:
481
514
value : $(params.shp-output-insecure)
482
515
- name : PARAM_CACHE
483
516
value : $(params.cache)
517
+ - name : PARAM_TARGET
518
+ value : $(params.target)
484
519
command :
485
520
- /bin/ash
486
521
args :
@@ -531,6 +566,9 @@ spec:
531
566
echo -n "An invalid value for the parameter 'cache' has been provided: '${PARAM_CACHE}'. Allowed values are 'disabled' and 'registry'." > '$(results.shp-error-message.path)'
532
567
exit 1
533
568
fi
569
+ if [ "${PARAM_TARGET}" != "" ]; then
570
+ echo "--opt=target=${PARAM_TARGET} \\" >> /tmp/run.sh
571
+ fi
534
572
535
573
stage=""
536
574
platforms=""
@@ -729,6 +767,8 @@ spec:
729
767
- --no-push
730
768
- --tar-path
731
769
- $(params.shp-output-directory)/image.tar
770
+ - --target
771
+ - $(params.target)
732
772
# https://github.com/GoogleContainerTools/kaniko/issues/2164
733
773
- --ignore-path
734
774
- /product_uuid
@@ -744,6 +784,10 @@ spec:
744
784
description : The path to the Dockerfile to be used for building the image.
745
785
type : string
746
786
default : " Dockerfile"
787
+ - name : target
788
+ description : " Sets the target stage to be built."
789
+ type : string
790
+ default : " "
747
791
securityContext :
748
792
runAsUser : 0
749
793
runAsGroup : 0
@@ -760,7 +804,7 @@ spec:
760
804
default : " "
761
805
- name : go-version
762
806
description : " Version of Go, must match a tag from https://hub.docker.com/_/golang?tab=tags"
763
- default : " 1.22 "
807
+ default : " 1.23 "
764
808
- name : ko-version
765
809
description : " Version of ko, must be either 'latest', or a release name from https://github.com/ko-build/ko/releases"
766
810
default : latest
@@ -890,7 +934,7 @@ spec:
890
934
- name : s2i
891
935
mountPath : /s2i
892
936
- name : buildah
893
- image : quay.io/containers/buildah:v1.37.5
937
+ image : quay.io/containers/buildah:v1.38.1
894
938
imagePullPolicy : Always
895
939
workingDir : /s2i
896
940
securityContext :
0 commit comments