Switch from buildkit to buildah.

BuildKit caching is not working but buildah caching works perfectly.
This commit is contained in:
Tom Alexander
2026-10-21 09:38:34 -04:00
parent faf279292a
commit 1350ffdf92
4 changed files with 188 additions and 119 deletions

View File

@@ -7,7 +7,7 @@ metadata:
spec: spec:
timeouts: timeouts:
pipeline: "2h0m0s" pipeline: "2h0m0s"
tasks: "1h0m0s" tasks: "1h0m40s"
finally: "0h30m0s" finally: "0h30m0s"
taskRunTemplate: taskRunTemplate:
serviceAccountName: build-bot serviceAccountName: build-bot
@@ -103,36 +103,42 @@ spec:
- name: url - name: url
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
- name: revision - name: revision
value: dda7b690195b43e8b9859d1caf5dcbf48588ade1 value: 9c6d3bc418dc2f54d73bdfa984bce3eb6c65fd60
- name: pathInRepo - name: pathInRepo
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml value: task/buildah-rootless-daemonless/0.1/buildah-rootless-daemonless.yaml
params: params:
- name: OUTPUT - name: OUTPUT
value: >- value: >-
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true $(params.image-name):$(tasks.fetch-repository.results.commit)
- name: CONTEXT - name: CONTEXT
value: $(params.path-to-image-context) value: $(params.path-to-image-context)
- name: DOCKERFILE - name: DOCKERFILE
value: $(params.path-to-dockerfile) value: $(params.path-to-dockerfile)
- name: EXTRA_ARGS - name: EXTRA_ARGS
value: value:
- "--opt" - "--target"
- "target=$(params.target-name)" - "$(params.target-name)"
- --import-cache - --cache-from
- "type=registry,ref=$(params.image-name):buildcache" - "$(params.image-name)-buildcache"
- --export-cache - --cache-to
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true" - "$(params.image-name)-buildcache"
- --opt - --build-arg
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time) - "SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)"
- --opt - --build-arg
- "build-arg:NIX_SUBSTITUTERS=http://ncps.nix-pull-through-cache.svc.cluster.local:80 https://cache.nixos.org" - "NIX_SUBSTITUTERS=http://ncps.nix-pull-through-cache.svc.cluster.local:80 https://cache.nixos.org"
- name: BUILDKITD_TOML - name: REGISTRIES_CONF
value: | value: |
debug = true unqualified-search-registries = ["docker.io"]
[registry."docker.io"]
mirrors = ["dockerhub.dockerhub.svc.cluster.local"] [[registry]]
[registry."dockerhub.dockerhub.svc.cluster.local"] location = "dockerhub.dockerhub.svc.cluster.local"
http = true insecure = true
[[registry]]
location = "docker.io"
[[registry.mirror]]
location = "dockerhub.dockerhub.svc.cluster.local" # Replace with your mirror URL
insecure = true insecure = true
workspaces: workspaces:
- name: source - name: source
@@ -200,9 +206,48 @@ spec:
value: failure value: failure
- name: TARGET_URL - name: TARGET_URL
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)" value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
- name: cargo-cache-autoclean
taskSpec:
metadata: {}
params:
- name: docker-image
type: string
description: Docker image to run.
default: alpine:3.20
stepTemplate:
image: alpine:3.20
computeResources:
requests:
cpu: 10m
memory: 600Mi
workingDir: /workspace/source
workspaces:
- name: source
mountPath: /source
- name: cargo-cache
mountPath: /usr/local/cargo/registry
optional: true
steps:
- name: run
image: $(params.docker-image)
workingDir: "$(workspaces.source.path)"
command: [cargo, cache, --autoclean]
args: []
env:
- name: RUSTUP_PERMIT_COPY_RENAME
value: "true"
workspaces:
- name: source
workspace: git-source
- name: cargo-cache
workspace: cargo-cache
params:
- name: docker-image
value: "$(tasks.build-image.results.IMAGE_URL[0])"
workspaces: workspaces:
- name: git-source - name: git-source
- name: docker-credentials - name: docker-credentials
- name: cargo-cache
workspaces: workspaces:
- name: git-source - name: git-source
volumeClaimTemplate: volumeClaimTemplate:
@@ -214,6 +259,9 @@ spec:
requests: requests:
storage: 10Gi storage: 10Gi
subPath: rust-source subPath: rust-source
- name: cargo-cache
persistentVolumeClaim:
claimName: natter-cargo-cache-build
- name: docker-credentials - name: docker-credentials
secret: secret:
secretName: harbor-plain secretName: harbor-plain
@@ -225,4 +273,4 @@ spec:
- name: path-to-image-context - name: path-to-image-context
value: . value: .
- name: path-to-dockerfile - name: path-to-dockerfile
value: docker/natter/ value: docker/natter/Dockerfile

View File

@@ -7,7 +7,7 @@ metadata:
spec: spec:
timeouts: timeouts:
pipeline: "2h0m0s" pipeline: "2h0m0s"
tasks: "1h0m0s" tasks: "1h0m40s"
finally: "0h30m0s" finally: "0h30m0s"
taskRunTemplate: taskRunTemplate:
serviceAccountName: build-bot serviceAccountName: build-bot
@@ -103,34 +103,42 @@ spec:
- name: url - name: url
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
- name: revision - name: revision
value: dda7b690195b43e8b9859d1caf5dcbf48588ade1 value: 9c6d3bc418dc2f54d73bdfa984bce3eb6c65fd60
- name: pathInRepo - name: pathInRepo
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml value: task/buildah-rootless-daemonless/0.1/buildah-rootless-daemonless.yaml
params: params:
- name: OUTPUT - name: OUTPUT
value: >- value: >-
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true $(params.image-name):$(tasks.fetch-repository.results.commit)
- name: CONTEXT - name: CONTEXT
value: $(params.path-to-image-context) value: $(params.path-to-image-context)
- name: DOCKERFILE - name: DOCKERFILE
value: $(params.path-to-dockerfile) value: $(params.path-to-dockerfile)
- name: EXTRA_ARGS - name: EXTRA_ARGS
value: value:
- "--opt" - "--target"
- "target=$(params.target-name)" - "$(params.target-name)"
- --import-cache - --cache-from
- "type=registry,ref=$(params.image-name):buildcache" - "$(params.image-name)-buildcache"
- --export-cache - --cache-to
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true" - "$(params.image-name)-buildcache"
- --opt - --build-arg
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time) - "SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)"
- name: BUILDKITD_TOML - --build-arg
- "NIX_SUBSTITUTERS=http://ncps.nix-pull-through-cache.svc.cluster.local:80 https://cache.nixos.org"
- name: REGISTRIES_CONF
value: | value: |
debug = true unqualified-search-registries = ["docker.io"]
[registry."docker.io"]
mirrors = ["dockerhub.dockerhub.svc.cluster.local"] [[registry]]
[registry."dockerhub.dockerhub.svc.cluster.local"] location = "dockerhub.dockerhub.svc.cluster.local"
http = true insecure = true
[[registry]]
location = "docker.io"
[[registry.mirror]]
location = "dockerhub.dockerhub.svc.cluster.local" # Replace with your mirror URL
insecure = true insecure = true
workspaces: workspaces:
- name: source - name: source
@@ -180,7 +188,7 @@ spec:
- build-image - build-image
params: params:
- name: docker-image - name: docker-image
value: "$(tasks.build-image.results.IMAGE_URL[1])" value: "$(tasks.build-image.results.IMAGE_URL[0])"
- name: run-prettier - name: run-prettier
taskSpec: taskSpec:
metadata: {} metadata: {}
@@ -214,25 +222,25 @@ spec:
- build-image - build-image
params: params:
- name: docker-image - name: docker-image
value: "$(tasks.build-image.results.IMAGE_URL[1])" value: "$(tasks.build-image.results.IMAGE_URL[0])"
- name: commit-changes - name: commit-changes
taskSpec: taskRef:
metadata: {} resolver: git
stepTemplate: params:
image: alpine:3.20 - name: url
computeResources: value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
requests: - name: revision
cpu: 10m value: df36b3853a5657fd883015cdbf07ad6466918acf
memory: 600Mi - name: pathInRepo
workingDir: "$(workspaces.source.path)" value: task/git-cli/0.4/git-cli.yaml
steps: params:
- image: alpine/git:v2.34.2 - name: GIT_USER_NAME
name: commit-changes-step value: fluxcdbot
script: | - name: GIT_USER_EMAIL
#!/usr/bin/env sh value: "fluxcdbot@users.noreply.github.com"
set -euo pipefail - name: GIT_SCRIPT
git config --global user.email "fluxcdbot@users.noreply.github.com" value: |
git config --global user.name "fluxcdbot" pwd
git config --global --add safe.directory /workspace/source git config --global --add safe.directory /workspace/source
git_status=$(git status --porcelain) git_status=$(git status --porcelain)
if [ -n "$git_status" ]; then if [ -n "$git_status" ]; then
@@ -241,9 +249,6 @@ spec:
else else
echo "No changes to commit." echo "No changes to commit."
fi fi
env:
- name: "GIT_SSH_COMMAND"
value: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
workspaces: workspaces:
- name: source - name: source
workspace: git-source workspace: git-source
@@ -346,7 +351,7 @@ spec:
workspace: cargo-cache workspace: cargo-cache
params: params:
- name: docker-image - name: docker-image
value: "$(tasks.build-image.results.IMAGE_URL[1])" value: "$(tasks.build-image.results.IMAGE_URL[0])"
workspaces: workspaces:
- name: git-source - name: git-source
- name: docker-credentials - name: docker-credentials
@@ -376,4 +381,4 @@ spec:
- name: path-to-image-context - name: path-to-image-context
value: docker/natter_development/ value: docker/natter_development/
- name: path-to-dockerfile - name: path-to-dockerfile
value: docker/natter_development/ value: docker/natter_development/Dockerfile

View File

@@ -5,12 +5,12 @@ metadata:
labels: labels:
pdb: protect pdb: protect
spec: spec:
taskRunTemplate:
serviceAccountName: build-bot
timeouts: timeouts:
pipeline: "2h0m0s" pipeline: "2h0m0s"
tasks: "1h0m40s" tasks: "1h0m40s"
finally: "0h30m0s" finally: "0h30m0s"
taskRunTemplate:
serviceAccountName: build-bot
pipelineSpec: pipelineSpec:
params: params:
- name: image-name - name: image-name
@@ -103,34 +103,42 @@ spec:
- name: url - name: url
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
- name: revision - name: revision
value: dda7b690195b43e8b9859d1caf5dcbf48588ade1 value: 9c6d3bc418dc2f54d73bdfa984bce3eb6c65fd60
- name: pathInRepo - name: pathInRepo
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml value: task/buildah-rootless-daemonless/0.1/buildah-rootless-daemonless.yaml
params: params:
- name: OUTPUT - name: OUTPUT
value: >- value: >-
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true $(params.image-name):$(tasks.fetch-repository.results.commit)
- name: CONTEXT - name: CONTEXT
value: $(params.path-to-image-context) value: $(params.path-to-image-context)
- name: DOCKERFILE - name: DOCKERFILE
value: $(params.path-to-dockerfile) value: $(params.path-to-dockerfile)
- name: EXTRA_ARGS - name: EXTRA_ARGS
value: value:
- "--opt" - "--target"
- "target=$(params.target-name)" - "$(params.target-name)"
- --import-cache - --cache-from
- "type=registry,ref=$(params.image-name):buildcache" - "$(params.image-name)-buildcache"
- --export-cache - --cache-to
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true" - "$(params.image-name)-buildcache"
- --opt - --build-arg
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time) - "SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)"
- name: BUILDKITD_TOML - --build-arg
- "NIX_SUBSTITUTERS=http://ncps.nix-pull-through-cache.svc.cluster.local:80 https://cache.nixos.org"
- name: REGISTRIES_CONF
value: | value: |
debug = true unqualified-search-registries = ["docker.io"]
[registry."docker.io"]
mirrors = ["dockerhub.dockerhub.svc.cluster.local"] [[registry]]
[registry."dockerhub.dockerhub.svc.cluster.local"] location = "dockerhub.dockerhub.svc.cluster.local"
http = true insecure = true
[[registry]]
location = "docker.io"
[[registry.mirror]]
location = "dockerhub.dockerhub.svc.cluster.local" # Replace with your mirror URL
insecure = true insecure = true
workspaces: workspaces:
- name: source - name: source
@@ -139,7 +147,7 @@ spec:
workspace: docker-credentials workspace: docker-credentials
runAfter: runAfter:
- fetch-repository - fetch-repository
- name: run-cargo-clippy - name: run-test
taskSpec: taskSpec:
metadata: {} metadata: {}
params: params:
@@ -190,7 +198,7 @@ spec:
- build-image - build-image
params: params:
- name: docker-image - name: docker-image
value: "$(tasks.build-image.results.IMAGE_URL[1])" value: "$(tasks.build-image.results.IMAGE_URL[0])"
finally: finally:
- name: report-success - name: report-success
when: when:
@@ -287,7 +295,7 @@ spec:
workspace: cargo-cache workspace: cargo-cache
params: params:
- name: docker-image - name: docker-image
value: "$(tasks.build-image.results.IMAGE_URL[1])" value: "$(tasks.build-image.results.IMAGE_URL[0])"
workspaces: workspaces:
- name: git-source - name: git-source
- name: docker-credentials - name: docker-credentials
@@ -317,4 +325,4 @@ spec:
- name: path-to-image-context - name: path-to-image-context
value: docker/natter_development/ value: docker/natter_development/
- name: path-to-dockerfile - name: path-to-dockerfile
value: docker/natter_development/ value: docker/natter_development/Dockerfile

View File

@@ -103,34 +103,42 @@ spec:
- name: url - name: url
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
- name: revision - name: revision
value: dda7b690195b43e8b9859d1caf5dcbf48588ade1 value: 9c6d3bc418dc2f54d73bdfa984bce3eb6c65fd60
- name: pathInRepo - name: pathInRepo
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml value: task/buildah-rootless-daemonless/0.1/buildah-rootless-daemonless.yaml
params: params:
- name: OUTPUT - name: OUTPUT
value: >- value: >-
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true $(params.image-name):$(tasks.fetch-repository.results.commit)
- name: CONTEXT - name: CONTEXT
value: $(params.path-to-image-context) value: $(params.path-to-image-context)
- name: DOCKERFILE - name: DOCKERFILE
value: $(params.path-to-dockerfile) value: $(params.path-to-dockerfile)
- name: EXTRA_ARGS - name: EXTRA_ARGS
value: value:
- "--opt" - "--target"
- "target=$(params.target-name)" - "$(params.target-name)"
- --import-cache - --cache-from
- "type=registry,ref=$(params.image-name):buildcache" - "$(params.image-name)-buildcache"
- --export-cache - --cache-to
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true" - "$(params.image-name)-buildcache"
- --opt - --build-arg
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time) - "SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)"
- name: BUILDKITD_TOML - --build-arg
- "NIX_SUBSTITUTERS=http://ncps.nix-pull-through-cache.svc.cluster.local:80 https://cache.nixos.org"
- name: REGISTRIES_CONF
value: | value: |
debug = true unqualified-search-registries = ["docker.io"]
[registry."docker.io"]
mirrors = ["dockerhub.dockerhub.svc.cluster.local"] [[registry]]
[registry."dockerhub.dockerhub.svc.cluster.local"] location = "dockerhub.dockerhub.svc.cluster.local"
http = true insecure = true
[[registry]]
location = "docker.io"
[[registry.mirror]]
location = "dockerhub.dockerhub.svc.cluster.local" # Replace with your mirror URL
insecure = true insecure = true
workspaces: workspaces:
- name: source - name: source
@@ -139,7 +147,7 @@ spec:
workspace: docker-credentials workspace: docker-credentials
runAfter: runAfter:
- fetch-repository - fetch-repository
- name: run-cargo-test - name: run-test
taskSpec: taskSpec:
metadata: {} metadata: {}
params: params:
@@ -180,7 +188,7 @@ spec:
- build-image - build-image
params: params:
- name: docker-image - name: docker-image
value: "$(tasks.build-image.results.IMAGE_URL[1])" value: "$(tasks.build-image.results.IMAGE_URL[0])"
finally: finally:
- name: report-success - name: report-success
when: when:
@@ -277,7 +285,7 @@ spec:
workspace: cargo-cache workspace: cargo-cache
params: params:
- name: docker-image - name: docker-image
value: "$(tasks.build-image.results.IMAGE_URL[1])" value: "$(tasks.build-image.results.IMAGE_URL[0])"
workspaces: workspaces:
- name: git-source - name: git-source
- name: docker-credentials - name: docker-credentials
@@ -307,4 +315,4 @@ spec:
- name: path-to-image-context - name: path-to-image-context
value: docker/natter_development/ value: docker/natter_development/
- name: path-to-dockerfile - name: path-to-dockerfile
value: docker/natter_development/ value: docker/natter_development/Dockerfile