Companion repository for the article "Build multi-architecture container images with Kubernetes, Tekton and Buildah"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.7 KiB

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: buildah
spec:
params:
- name: buildahVersion
type: string
- name: buildahPlatforms
type: array
default:
- linux/amd64
- name: outputContainerImage
type: string
workspaces:
- name: src
mountPath: /src
- name: containers
mountPath: /var/lib/containers
steps:
- name: buildah
image: quay.io/containers/buildah:$(params.buildahVersion)
workingDir: /src
env:
- name: TARGET_IMAGE
value: "$(params.outputContainerImage)"
securityContext:
capabilities:
add:
- 'SYS_ADMIN'
privileged: true
args:
- "$(params.buildahPlatforms[*])"
script: |
#!/bin/bash
set -Eeuo pipefail
function build () {
echo "========================================================="
echo " buildah build $TARGET_IMAGE for ${1:-default}"
echo "========================================================="
echo
extra_args=""
if [ -n "${1:-}" ]; then
extra_args="$extra_args --platform $1"
fi
if [ -n "${CONTAINERFILE:-}" ]; then
extra_args="$extra_args --file $CONTAINERFILE"
fi
buildah bud --storage-driver vfs --manifest tekton -t $TARGET_IMAGE $extra_args .
echo
}
function push () {
echo "========================================================="
echo " buildah push $1"
echo "========================================================="
echo
buildah manifest push --storage-driver vfs --all tekton "docker://$1"
echo
}
for platform; do
build "$platform"
done
push "$TARGET_IMAGE:latest"
exit 0