2025-04-16 00:50:02 +00:00

82 lines
2.2 KiB
YAML

apiVersion: tekton.dev/v1
kind: Task
metadata:
name: docker-registry
spec:
params:
- name: home
type: string
default: ""
description: home directory
- name: workshop
type: string
default: ""
description: workshop 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 workshop)
workspaces:
- name: shared
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
image: alpine:3.21.3
workingDir: /workspace/shared/$(params.workshop)
env:
- name: HOME
value: /workspace/shared/$(params.home)
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.shared.path)/$(params.workshop)
env:
- name: HOME
value: /workspace/shared/$(params.home)
- name: DOCKER_CONFIG
value: $HOME/.dockerconfigjson
command:
- /kaniko/executor
args:
- --dockerfile=$(params.dockerfile)
- --context=$(params.context)
- --destination=$(params.imageName):$(params.tag)
- --skip-tls-verify
- --verbosity=info
- --reproducible