8 changed files with 126 additions and 60 deletions
@ -0,0 +1,5 @@ |
|||||
|
resources: |
||||
|
- pipeline.yaml |
||||
|
- serviceaccount-buildbot.yaml |
||||
|
- task-buildah-build.yaml |
||||
|
- task-buildah-push.yaml |
||||
@ -1,7 +0,0 @@ |
|||||
apiVersion: v1 |
|
||||
kind: Secret |
|
||||
metadata: |
|
||||
name: quay-authentication |
|
||||
data: |
|
||||
.dockerconfigjson: REDACTED |
|
||||
type: kubernetes.io/dockerconfigjson |
|
||||
@ -1,29 +1,35 @@ |
|||||
apiVersion: tekton.dev/v1beta1 |
apiVersion: tekton.dev/v1beta1 |
||||
kind: Task |
kind: Task |
||||
metadata: |
metadata: |
||||
name: podman-build |
name: buildah-build |
||||
spec: |
spec: |
||||
params: |
params: |
||||
- name: manifest-name |
|
||||
type: string |
|
||||
- name: context-dir |
- name: context-dir |
||||
type: string |
type: string |
||||
default: . |
default: . |
||||
workspaces: |
workspaces: |
||||
- name: source-workspace |
- name: source-workspace |
||||
description: Workspace containing source code |
description: Workspace containing source code |
||||
|
- name: oci-images |
||||
|
mountPath: /srv/oci-images |
||||
|
volumes: |
||||
- name: container-storage |
- name: container-storage |
||||
description: Persistent volume to store container images |
emptyDir: {} |
||||
mountPath: /var/lib/containers |
|
||||
steps: |
steps: |
||||
- name: build |
- name: build |
||||
image: registry.redhat.io/rhel8/buildah@sha256:b48f410efa0ff8ab0db6ead420a5d8d866d64af846fece5efb185230d7ecf591 |
image: registry.redhat.io/rhel8/buildah@sha256:b48f410efa0ff8ab0db6ead420a5d8d866d64af846fece5efb185230d7ecf591 |
||||
|
env: |
||||
|
- name: STORAGE_DRIVER |
||||
|
value: vfs |
||||
script: | |
script: | |
||||
#!/bin/bash |
#!/bin/bash |
||||
set -Eeuo pipefail |
set -Eeuo pipefail |
||||
buildah bud --storage-driver=vfs --no-cache --manifest $(params.manifest-name) $(workspaces.source-workspace.path)/$(params.context-dir) |
buildah bud -t localhost/image:$(uname -m) $(workspaces.source-workspace.path)/$(params.context-dir) |
||||
#podman build --no-cache --manifest $(params.manifest-name) $(workspaces.source-workspace.path)/$(params.context-dir) |
buildah push localhost/image:$(uname -m) oci-archive:/srv/oci-images/$(uname -m).tar |
||||
securityContext: |
securityContext: |
||||
capabilities: |
capabilities: |
||||
add: |
add: |
||||
- SETFCAP |
- SETFCAP |
||||
|
volumeMounts: |
||||
|
- name: container-storage |
||||
|
mountPath: /var/lib/containers |
||||
@ -0,0 +1,59 @@ |
|||||
|
apiVersion: tekton.dev/v1beta1 |
||||
|
kind: Task |
||||
|
metadata: |
||||
|
name: buildah-push |
||||
|
spec: |
||||
|
params: |
||||
|
- name: image-name |
||||
|
type: string |
||||
|
- name: architectures |
||||
|
type: array |
||||
|
workspaces: |
||||
|
- name: oci-images |
||||
|
mountPath: /srv/oci-images |
||||
|
- description: An optional workspace that allows providing a .docker/config.json file for Buildah to access the container registry. The file should be placed at the root of the Workspace with name config.json or .dockerconfigjson. |
||||
|
name: dockerconfig |
||||
|
optional: true |
||||
|
volumes: |
||||
|
- name: container-storage |
||||
|
emptyDir: {} |
||||
|
steps: |
||||
|
- name: push |
||||
|
image: registry.redhat.io/rhel8/buildah@sha256:b48f410efa0ff8ab0db6ead420a5d8d866d64af846fece5efb185230d7ecf591 |
||||
|
env: |
||||
|
- name: STORAGE_DRIVER |
||||
|
value: vfs |
||||
|
args: |
||||
|
- "$(params.architectures[*])" |
||||
|
script: | |
||||
|
#!/bin/bash |
||||
|
set -Eeuo pipefail |
||||
|
|
||||
|
# Handle registry credentials |
||||
|
if [[ "$(workspaces.dockerconfig.bound)" == "true" ]]; then |
||||
|
if test -f "$(workspaces.dockerconfig.path)/config.json"; then |
||||
|
export DOCKER_CONFIG="$(workspaces.dockerconfig.path)" |
||||
|
elif test -f "$(workspaces.dockerconfig.path)/.dockerconfigjson"; then |
||||
|
cp "$(workspaces.dockerconfig.path)/.dockerconfigjson" "$HOME/.docker/config.json" |
||||
|
export DOCKER_CONFIG="$HOME/.docker" |
||||
|
else |
||||
|
echo "neither 'config.json' nor '.dockerconfigjson' found at workspace root" |
||||
|
exit 1 |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
declare -a iids=() |
||||
|
for arch; do |
||||
|
echo "Loading image for architecture $arch..." |
||||
|
iid=$(buildah pull oci-archive:/srv/oci-images/$arch.tar) |
||||
|
iids+=("$iid") |
||||
|
done |
||||
|
buildah manifest create localhost/multi-arch-image "${iids[@]}" |
||||
|
buildah manifest push --all localhost/multi-arch-image docker://$(params.image-name) |
||||
|
securityContext: |
||||
|
capabilities: |
||||
|
add: |
||||
|
- SETFCAP |
||||
|
volumeMounts: |
||||
|
- name: container-storage |
||||
|
mountPath: /var/lib/containers |
||||
@ -1,22 +0,0 @@ |
|||||
apiVersion: tekton.dev/v1beta1 |
|
||||
kind: Task |
|
||||
metadata: |
|
||||
name: buildah-push |
|
||||
spec: |
|
||||
params: |
|
||||
- name: image-name |
|
||||
type: string |
|
||||
- name: manifest-name |
|
||||
type: string |
|
||||
workspaces: |
|
||||
- name: container-storage |
|
||||
description: Persistent volume to store container images |
|
||||
mountPath: /var/lib/containers |
|
||||
steps: |
|
||||
- name: push |
|
||||
image: quay.io/podman/stable |
|
||||
script: | |
|
||||
#!/bin/bash |
|
||||
set -Eeuo pipefail |
|
||||
export STORAGE_DRIVER=vfs |
|
||||
buildah manifest push --all $(params.manifest-name) docker://$(params.image-name) |
|
||||
Loading…
Reference in new issue