apiVersion: tekton.dev/v1 kind: Task metadata: name: docker-registry spec: params: - name: subdirectory type: string default: "" description: Subdirectory within the repo where the source code is located - name: imageName type: string description: Base image name with registry (e.g. docker.unbox-x.net/registry/unbox-x-aisi-cron-app) - name: tag type: string description: Version tag to apply to the image (e.g. v0.2.0) - name: dockerfile type: string default: ./Dockerfile description: Path to Dockerfile - name: context type: string default: . description: Build context path (relative to subdirectory) workspaces: - name: source description: Source code workspace - name: docker-dot-credentials description: Workspace containing config.json (as Secret) results: - name: imageUrl description: Final pushed image URL with tag (e.g. registry/app:v0.2.0) steps: - name: prepare-docker-auth image: alpine:3.21.3 workingDir: /workspace/source/$(params.subdirectory) script: | #!/bin/sh set -e echo "🔐 Copying docker .dockerconfigjson to /tekton/home/.docker" mkdir -p /tekton/home/.docker cp /workspace/docker-dot-credentials/.dockerconfigjson /tekton/home/.docker/config.json IMAGE="$(params.imageName):$(params.tag)" echo "📦 Using image: $IMAGE" echo -n "$IMAGE" > /tekton/results/imageUrl - name: kaniko-build image: gcr.io/kaniko-project/executor:v1.23.2 workingDir: $(workspaces.source.path)/$(params.subdirectory) env: - name: DOCKER_CONFIG value: /tekton/home/.docker command: - /kaniko/executor args: - --dockerfile=$(params.dockerfile) - --context=$(params.context) - --destination=$(params.imageName):$(params.tag) - --skip-tls-verify - --verbosity=info - --reproducible {{- if $(params.kanikoArgs) }} {{- range $arg := splitList " " "$(params.kanikoArgs)" }} - {{ $arg }} {{- end }} {{- end }}