Skip to content

Commit 7c692d8

Browse files
Merge pull request #254 from adambkaplan/build-strategies-v0.15.2
feat: Deploy Build v0.15 Build Strategies
2 parents 1b2e9ac + 930e9cb commit 7c692d8

File tree

3 files changed

+69
-25
lines changed

3 files changed

+69
-25
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6-
VERSION ?= 0.15.0-rc0
6+
VERSION ?= 0.15.2
77

88
# CHANNELS define the bundle channels used in the bundle.
99
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")

bundle/manifests/shipwright-operator.clusterserviceversion.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ metadata:
2424
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
2525
repository: https://github.com/shipwright-io/operator
2626
support: The Shipwright Contributors
27-
name: shipwright-operator.v0.15.0-rc0
27+
name: shipwright-operator.v0.15.2
2828
namespace: placeholder
2929
spec:
3030
apiservicedefinitions: {}
@@ -785,4 +785,4 @@ spec:
785785
provider:
786786
name: The Shipwright Contributors
787787
url: https://shipwright.io
788-
version: 0.15.0-rc0
788+
version: 0.15.2

kodata/samples/buildstrategy/sample-strategies.yaml

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
spec:
66
steps:
77
- name: build
8-
image: quay.io/containers/buildah:v1.37.5
8+
image: quay.io/containers/buildah:v1.38.1
99
imagePullPolicy: Always
1010
workingDir: $(params.shp-source-root)
1111
securityContext:
@@ -21,8 +21,8 @@ spec:
2121
context=
2222
dockerfile=
2323
image=
24-
target=
25-
buildArgs=()
24+
outputDirectory=
25+
budArgs=()
2626
inBuildArgs=false
2727
registriesBlock=""
2828
inRegistriesBlock=false
@@ -55,12 +55,21 @@ spec:
5555
inRegistriesSearch=false
5656
image="$1"
5757
shift
58+
elif [ "${arg}" == "--output-directory" ]; then
59+
inBuildArgs=false
60+
inRegistriesBlock=false
61+
inRegistriesInsecure=false
62+
inRegistriesSearch=false
63+
outputDirectory="$1"
64+
shift
5865
elif [ "${arg}" == "--target" ]; then
5966
inBuildArgs=false
6067
inRegistriesBlock=false
6168
inRegistriesInsecure=false
6269
inRegistriesSearch=false
63-
target="$1"
70+
if [ "$1" != "" ]; then
71+
budArgs+=(--target "$1")
72+
fi
6473
shift
6574
elif [ "${arg}" == "--build-args" ]; then
6675
inBuildArgs=true
@@ -83,7 +92,7 @@ spec:
8392
inRegistriesBlock=false
8493
inRegistriesInsecure=false
8594
elif [ "${inBuildArgs}" == "true" ]; then
86-
buildArgs+=("--build-arg" "${arg}")
95+
budArgs+=(--build-arg "${arg}")
8796
elif [ "${inRegistriesBlock}" == "true" ]; then
8897
registriesBlock="${registriesBlock}'${arg}', "
8998
elif [ "${inRegistriesInsecure}" == "true" ]; then
@@ -139,7 +148,7 @@ spec:
139148
# Building the image
140149
echo "[INFO] Building image ${image}"
141150
buildah --storage-driver=$(params.storage-driver) \
142-
bud "${buildArgs[@]}" \
151+
bud "${budArgs[@]}" \
143152
--registries-conf=/tmp/registries.conf \
144153
--tag="${image}" \
145154
--file="${dockerfile}" \
@@ -149,11 +158,13 @@ spec:
149158
echo "[INFO] Writing image ${image}"
150159
buildah --storage-driver=$(params.storage-driver) push \
151160
"${image}" \
152-
"oci:${target}"
161+
"oci:${outputDirectory}"
153162
# That's the separator between the shell script and its args
154163
- --
155164
- --context
156165
- $(params.shp-source-context)
166+
- --output-directory
167+
- $(params.shp-output-directory)
157168
- --dockerfile
158169
- $(params.dockerfile)
159170
- --image
@@ -167,7 +178,7 @@ spec:
167178
- --registries-search
168179
- $(params.registries-search[*])
169180
- --target
170-
- $(params.shp-output-directory)
181+
- $(params.target)
171182
resources:
172183
limits:
173184
cpu: "1"
@@ -203,6 +214,10 @@ spec:
203214
type: string
204215
default: "vfs"
205216
# 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: ""
206221
securityContext:
207222
runAsUser: 0
208223
runAsGroup: 0
@@ -215,7 +230,7 @@ metadata:
215230
spec:
216231
steps:
217232
- name: build-and-push
218-
image: quay.io/containers/buildah:v1.37.5
233+
image: quay.io/containers/buildah:v1.38.1
219234
imagePullPolicy: Always
220235
workingDir: $(params.shp-source-root)
221236
securityContext:
@@ -233,7 +248,7 @@ spec:
233248
context=
234249
dockerfile=
235250
image=
236-
buildArgs=()
251+
budArgs=()
237252
inBuildArgs=false
238253
registriesBlock=""
239254
inRegistriesBlock=false
@@ -267,6 +282,15 @@ spec:
267282
inRegistriesSearch=false
268283
image="$1"
269284
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
270294
elif [ "${arg}" == "--build-args" ]; then
271295
inBuildArgs=true
272296
inRegistriesBlock=false
@@ -288,7 +312,7 @@ spec:
288312
inRegistriesBlock=false
289313
inRegistriesInsecure=false
290314
elif [ "${inBuildArgs}" == "true" ]; then
291-
buildArgs+=("--build-arg" "${arg}")
315+
budArgs+=(--build-arg "${arg}")
292316
elif [ "${inRegistriesBlock}" == "true" ]; then
293317
registriesBlock="${registriesBlock}'${arg}', "
294318
elif [ "${inRegistriesInsecure}" == "true" ]; then
@@ -349,7 +373,7 @@ spec:
349373
# Building the image
350374
echo "[INFO] Building image ${image}"
351375
buildah --storage-driver=$(params.storage-driver) \
352-
bud "${buildArgs[@]}" \
376+
bud "${budArgs[@]}" \
353377
--registries-conf=/tmp/registries.conf \
354378
--tag="${image}" \
355379
--file="${dockerfile}" \
@@ -378,6 +402,8 @@ spec:
378402
- $(params.registries-insecure[*])
379403
- --registries-search
380404
- $(params.registries-search[*])
405+
- --target
406+
- $(params.target)
381407
resources:
382408
limits:
383409
cpu: "1"
@@ -409,10 +435,14 @@ spec:
409435
type: string
410436
default: "Dockerfile"
411437
- 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'."
413439
type: string
414440
default: "vfs"
415441
# 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: ""
416446
securityContext:
417447
runAsUser: 0
418448
runAsGroup: 0
@@ -425,9 +455,6 @@ metadata:
425455
annotations:
426456
# See https://github.com/moby/buildkit/blob/master/docs/rootless.md#about---oci-worker-no-process-sandbox for more information
427457
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
431458
spec:
432459
parameters:
433460
- name: build-args
@@ -438,6 +465,10 @@ spec:
438465
description: "Configure BuildKit's cache usage. Allowed values are 'disabled' and 'registry'. The default is 'registry'."
439466
type: string
440467
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
441472
- name: platforms
442473
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."
443474
type: array
@@ -446,20 +477,22 @@ spec:
446477
description: "The secrets to pass to the build. Values must be in the format ID=FILE_CONTENT."
447478
type: array
448479
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."
451482
type: string
452-
default: "Dockerfile"
483+
default: ""
453484
steps:
454485
- name: build-and-push
455-
image: moby/buildkit:v0.17.0-rootless
486+
image: moby/buildkit:v0.20.0-rootless
456487
imagePullPolicy: Always
457488
securityContext:
458489
allowPrivilegeEscalation: true
459490
capabilities:
460491
add:
461492
- SETGID
462493
- SETUID
494+
seccompProfile:
495+
type: Unconfined
463496
workingDir: $(params.shp-source-root)
464497
env:
465498
- name: DOCKER_CONFIG
@@ -481,6 +514,8 @@ spec:
481514
value: $(params.shp-output-insecure)
482515
- name: PARAM_CACHE
483516
value: $(params.cache)
517+
- name: PARAM_TARGET
518+
value: $(params.target)
484519
command:
485520
- /bin/ash
486521
args:
@@ -531,6 +566,9 @@ spec:
531566
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)'
532567
exit 1
533568
fi
569+
if [ "${PARAM_TARGET}" != "" ]; then
570+
echo "--opt=target=${PARAM_TARGET} \\" >> /tmp/run.sh
571+
fi
534572
535573
stage=""
536574
platforms=""
@@ -729,6 +767,8 @@ spec:
729767
- --no-push
730768
- --tar-path
731769
- $(params.shp-output-directory)/image.tar
770+
- --target
771+
- $(params.target)
732772
# https://github.com/GoogleContainerTools/kaniko/issues/2164
733773
- --ignore-path
734774
- /product_uuid
@@ -744,6 +784,10 @@ spec:
744784
description: The path to the Dockerfile to be used for building the image.
745785
type: string
746786
default: "Dockerfile"
787+
- name: target
788+
description: "Sets the target stage to be built."
789+
type: string
790+
default: ""
747791
securityContext:
748792
runAsUser: 0
749793
runAsGroup: 0
@@ -760,7 +804,7 @@ spec:
760804
default: ""
761805
- name: go-version
762806
description: "Version of Go, must match a tag from https://hub.docker.com/_/golang?tab=tags"
763-
default: "1.22"
807+
default: "1.23"
764808
- name: ko-version
765809
description: "Version of ko, must be either 'latest', or a release name from https://github.com/ko-build/ko/releases"
766810
default: latest
@@ -890,7 +934,7 @@ spec:
890934
- name: s2i
891935
mountPath: /s2i
892936
- name: buildah
893-
image: quay.io/containers/buildah:v1.37.5
937+
image: quay.io/containers/buildah:v1.38.1
894938
imagePullPolicy: Always
895939
workingDir: /s2i
896940
securityContext:

0 commit comments

Comments
 (0)