Skip to content

Commit

Permalink
Buildah: Add SKIP_UNUSED_STAGES parameter
Browse files Browse the repository at this point in the history
Expose the --skip-unused-stages argument to Buildah as a parameter.
This is needed to handle certain Containerfiles where stages have
hidden side-effects like writing things to the context directory.

See containers/buildah#5529 for
details.
  • Loading branch information
owtaylor committed May 21, 2024
1 parent 7f8a9fd commit 04a53a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions task/buildah-remote/0.1/buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ spec:
description: Path to a file with build arguments, see https://www.mankier.com/1/buildah-build#--build-arg-file
name: BUILD_ARGS_FILE
type: string
- default: "true"
description: Whether to skip stages in Containerfile that seem unused by subsequent
stages
name: SKIP_UNUSED_STAGES
type: string
- description: The platform to build on
name: PLATFORM
type: string
Expand Down Expand Up @@ -135,6 +140,8 @@ spec:
value: $(params.ENTITLEMENT_SECRET)
- name: BUILD_ARGS_FILE
value: $(params.BUILD_ARGS_FILE)
- name: SKIP_UNUSED_STAGES
value: $(params.SKIP_UNUSED_STAGES)
- name: BUILDER_IMAGE
value: quay.io/redhat-appstudio/buildah:v1.31.0@sha256:34f12c7b72ec2c28f1ded0c494b428df4791c909f1f174dd21b8ed6a57cf5ddb
steps:
Expand Down Expand Up @@ -252,6 +259,10 @@ spec:
BUILDAH_ARGS+=("--build-arg=$build_arg")
done
if [ "${SKIP_UNUSED_STAGES}" != "true" ] ; then
BUILDAH_ARGS+=("--skip-unused-stages=false")
fi
if [ -d "$(workspaces.source.path)/cachi2" ]; then
cp -r "$(workspaces.source.path)/cachi2" /tmp/
chmod -R go+rwX /tmp/cachi2
Expand Down Expand Up @@ -342,6 +353,7 @@ spec:
-e PARAM_BUILDER_IMAGE="$PARAM_BUILDER_IMAGE" \
-e ENTITLEMENT_SECRET="$ENTITLEMENT_SECRET" \
-e BUILD_ARGS_FILE="$BUILD_ARGS_FILE" \
-e SKIP_UNUSED_STAGES="$SKIP_UNUSED_STAGES" \
-e COMMIT_SHA="$COMMIT_SHA" \
-v "$BUILD_DIR/workspaces/source:$(workspaces.source.path):Z" \
-v "$BUILD_DIR/.docker/:/root/.docker:Z" \
Expand Down
10 changes: 10 additions & 0 deletions task/buildah/0.1/buildah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ spec:
description: Path to a file with build arguments, see https://www.mankier.com/1/buildah-build#--build-arg-file
type: string
default: ""
- name: SKIP_UNUSED_STAGES
description: Whether to skip stages in Containerfile that seem unused by subsequent stages
type: string
default: "true"

results:
- description: Digest of the image just built
Expand Down Expand Up @@ -124,6 +128,8 @@ spec:
value: $(params.ENTITLEMENT_SECRET)
- name: BUILD_ARGS_FILE
value: $(params.BUILD_ARGS_FILE)
- name: SKIP_UNUSED_STAGES
value: $(params.SKIP_UNUSED_STAGES)

steps:
- image: quay.io/redhat-appstudio/buildah:v1.31.0@sha256:34f12c7b72ec2c28f1ded0c494b428df4791c909f1f174dd21b8ed6a57cf5ddb
Expand Down Expand Up @@ -205,6 +211,10 @@ spec:
BUILDAH_ARGS+=("--build-arg=$build_arg")
done
if [ "${SKIP_UNUSED_STAGES}" != "true" ] ; then
BUILDAH_ARGS+=("--skip-unused-stages=false")
fi
if [ -d "$(workspaces.source.path)/cachi2" ]; then
cp -r "$(workspaces.source.path)/cachi2" /tmp/
chmod -R go+rwX /tmp/cachi2
Expand Down

0 comments on commit 04a53a2

Please sign in to comment.