2026-01-19 13:57:50 +01:00
|
|
|
# Tekton Kaniko Build Task for Bakery-IA CI/CD
|
|
|
|
|
# This task builds and pushes container images using Kaniko
|
|
|
|
|
|
|
|
|
|
apiVersion: tekton.dev/v1beta1
|
|
|
|
|
kind: Task
|
|
|
|
|
metadata:
|
|
|
|
|
name: kaniko-build
|
|
|
|
|
namespace: {{ .Values.namespace }}
|
|
|
|
|
labels:
|
|
|
|
|
app.kubernetes.io/name: {{ .Values.labels.app.name }}
|
|
|
|
|
app.kubernetes.io/component: build
|
|
|
|
|
spec:
|
|
|
|
|
workspaces:
|
|
|
|
|
- name: source
|
|
|
|
|
description: Workspace containing the source code
|
|
|
|
|
- name: docker-credentials
|
|
|
|
|
description: Docker registry credentials
|
|
|
|
|
params:
|
|
|
|
|
- name: services
|
|
|
|
|
type: string
|
|
|
|
|
description: Comma-separated list of services to build
|
|
|
|
|
- name: registry
|
|
|
|
|
type: string
|
|
|
|
|
description: Container registry URL
|
|
|
|
|
- name: git-revision
|
|
|
|
|
type: string
|
|
|
|
|
description: Git revision to tag images with
|
|
|
|
|
results:
|
|
|
|
|
- name: build-status
|
|
|
|
|
description: Status of the build operation
|
|
|
|
|
steps:
|
|
|
|
|
- name: build-and-push
|
|
|
|
|
image: gcr.io/kaniko-project/executor:v1.15.0
|
|
|
|
|
env:
|
|
|
|
|
- name: DOCKER_CONFIG
|
|
|
|
|
value: /tekton/home/.docker
|
2026-01-19 14:22:07 +01:00
|
|
|
script: |
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
# Split services parameter by comma
|
|
|
|
|
IFS=',' read -ra SERVICES <<< "$(params.services)"
|
|
|
|
|
|
|
|
|
|
# Build each service
|
|
|
|
|
for service in "${SERVICES[@]}"; do
|
|
|
|
|
service=$(echo "$service" | xargs) # Trim whitespace
|
|
|
|
|
if [ -n "$service" ] && [ "$service" != "none" ]; then
|
|
|
|
|
echo "Building service: $service"
|
|
|
|
|
/kaniko/executor \
|
|
|
|
|
--dockerfile="$(workspaces.source.path)/services/$service/Dockerfile" \
|
|
|
|
|
--destination="$(params.registry)/$service:$(params.git-revision)" \
|
|
|
|
|
--context="$(workspaces.source.path)" \
|
|
|
|
|
--cache=true \
|
|
|
|
|
--cache-repo="$(params.registry)/cache"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "success" > $(results.build-status.path)
|
2026-01-19 13:57:50 +01:00
|
|
|
resources:
|
|
|
|
|
limits:
|
|
|
|
|
cpu: 2000m
|
|
|
|
|
memory: 4Gi
|
|
|
|
|
requests:
|
|
|
|
|
cpu: 500m
|
|
|
|
|
memory: 1Gi
|