Switch to a new Tekton task I've written to use buildkit instead of kaniko to build docker images.

This commit is contained in:
Tom Alexander 2024-10-19 23:15:35 -04:00
parent 79c5c7e589
commit 09e8c700d2
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -44,6 +44,31 @@ spec:
#!/usr/bin/env sh #!/usr/bin/env sh
set -euo pipefail set -euo pipefail
echo -n "$(date +%s)" | tee $(results.unix-time.path) echo -n "$(date +%s)" | tee $(results.unix-time.path)
- name: get-git-commit-time
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.20
computeResources:
requests:
cpu: 10m
memory: 600Mi
workingDir: "$(workspaces.repo.path)"
results:
- name: unix-time
description: The time of the git commit in unix timestamp format.
steps:
- image: alpine/git:v2.34.2
name: detect-tag-step
script: |
#!/usr/bin/env sh
set -euo pipefail
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
workspaces:
- name: repo
workspace: git-source
runAfter:
- fetch-repository
- name: report-pending - name: report-pending
taskRef: taskRef:
resolver: git resolver: git
@ -184,32 +209,35 @@ spec:
resolver: git resolver: git
params: params:
- name: url - name: url
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
- name: revision - name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf value: 8e4e323389e66d8365a3243f8e956136e916132e
- name: pathInRepo - name: pathInRepo
value: task/kaniko/0.6/kaniko.yaml value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
params: params:
- name: IMAGE - name: OUTPUT
value: "harbor.fizz.buzz/private/homepage-build-organic:$(tasks.get-time.results.unix-time)" value: >-
type=image,"name=harbor.fizz.buzz/private/homepage-build-organic:latest,harbor.fizz.buzz/private/homepage-build-organic:$(tasks.get-time.results.unix-time)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
- name: CONTEXT - name: CONTEXT
value: . value: .
- name: DOCKERFILE - name: DOCKERFILE
value: docker/organic/Dockerfile value: docker/organic/
- name: BUILDER_IMAGE
value: "gcr.io/kaniko-project/executor:v1.23.2"
- name: EXTRA_ARGS - name: EXTRA_ARGS
value: value:
- "--destination=harbor.fizz.buzz/private/homepage-build-organic" # Also write the :latest image - --import-cache
- "--target=" - "type=registry,ref=harbor.fizz.buzz/private/homepage-build-organic:buildcache"
- --cache=true - --export-cache
- --cache-copy-layers - "type=registry,ref=harbor.fizz.buzz/private/homepage-build-organic:buildcache,mode=max,compression=zstd,compression-level=3,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
- --cache-repo=harbor.fizz.buzz/kanikocache/cache - --opt
- --use-new-run # Should result in a speed-up - build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
- --reproducible # To remove timestamps so layer caching works. - name: BUILDKITD_TOML
- --snapshot-mode=redo value: |
- --skip-unused-stages=true debug = true
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local [registry."docker.io"]
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
[registry."dockerhub.dockerhub.svc.cluster.local"]
http = true
insecure = true
workspaces: workspaces:
- name: source - name: source
workspace: git-source workspace: git-source
@ -232,7 +260,7 @@ spec:
name: build-explorer-wasm name: build-explorer-wasm
params: params:
- name: IMAGE - name: IMAGE
value: "harbor.fizz.buzz/private/homepage-build-organic:$(tasks.get-time.results.unix-time)" value: "$(tasks.build-explorer-image.results.IMAGE_URL[1])"
workspaces: workspaces:
- name: organic - name: organic
workspace: git-source-organic workspace: git-source-organic