apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: docker-registry spec: params: - name: subdirectory type: string description: Subdirectory within the repo where the source code is located default: "" - name: imageName description: Base image name with registry (e.g. registry.unbox-x.net/unbox-x-aisi-cron-app) type: string - name: tag description: Version tag to apply to the image (e.g. v0.2.0) type: string - name: dockerfile description: Path to Dockerfile type: string default: ./Dockerfile - name: context description: Build context path (relative to subdirectory) type: string default: . workspaces: - name: source description: Source code workspace - name: docker-auth description: Docker registry credentials (username + password) results: - name: imageUrl description: Final pushed image URL with tag (e.g. registry/app:v0.2.0) steps: - name: build-and-push image: gcr.io/kaniko-project/executor:v1.23.2 workingDir: /workspace/source env: - name: DOCKER_CONFIG value: /tekton/home/.docker args: - > echo "📦 Using image: $(params.imageName):$(params.tag)" && USERNAME=$(cat /workspace/docker-auth/username) && PASSWORD=$(cat /workspace/docker-auth/password) && REGISTRY=$(echo "$(params.imageName)" | cut -d/ -f1) && echo "🔐 Creating Docker config..." && mkdir -p /tekton/home/.docker && echo '{ "auths": { "'$REGISTRY'": { "username": "'$USERNAME'", "password": "'$PASSWORD'", "auth": "'$(echo -n $USERNAME:$PASSWORD | base64)'" } } }' > /tekton/home/.docker/config.json && /kaniko/executor \ --dockerfile=$(params.dockerfile) \ --context=$(params.context) \ --destination="$(params.imageName):$(params.tag)" \ --skip-tls-verify \ --reproducible \ --verbosity=info && echo -n "$(params.imageName):$(params.tag)" > /tekton/results/imageUrl