- Add git-clone task for repository cloning - Add kaniko-build task for container image builds - Add container-build pipeline orchestrating clone + build - Add harbor-credentials ExternalSecret for innoventions namespace - Add test-app.Dockerfile for pipeline validation Day 3 deliverables for Tekton Phase 2
100 lines
3.0 KiB
YAML
100 lines
3.0 KiB
YAML
apiVersion: tekton.dev/v1beta1
|
|
kind: Pipeline
|
|
metadata:
|
|
name: container-build
|
|
namespace: innoventions
|
|
labels:
|
|
app.kubernetes.io/version: "0.1"
|
|
annotations:
|
|
tekton.dev/pipelines.minVersion: "0.29.0"
|
|
tekton.dev/categories: Container Build
|
|
tekton.dev/tags: git, kaniko, build
|
|
tekton.dev/displayName: "Container Build Pipeline"
|
|
spec:
|
|
description: >-
|
|
This pipeline clones a git repository and builds a container image from it using Kaniko.
|
|
|
|
The pipeline performs the following steps:
|
|
1. Clone the git repository to a shared workspace
|
|
2. Build and push the container image to Harbor registry
|
|
|
|
params:
|
|
- name: git-url
|
|
type: string
|
|
description: The git repository URL to clone
|
|
- name: git-revision
|
|
type: string
|
|
description: The git revision (branch, tag, sha) to checkout
|
|
default: "main"
|
|
- name: image-name
|
|
type: string
|
|
description: The complete image name including registry (e.g., the-seas.local.mk-labs.cloud/library/app)
|
|
- name: image-tag
|
|
type: string
|
|
description: The image tag to apply
|
|
default: "latest"
|
|
- name: dockerfile
|
|
type: string
|
|
description: Path to the Dockerfile relative to the repository root
|
|
default: "./Dockerfile"
|
|
- name: context
|
|
type: string
|
|
description: Path to the build context relative to the repository root
|
|
default: "./"
|
|
|
|
workspaces:
|
|
- name: shared-workspace
|
|
description: |
|
|
This workspace will hold the cloned git repository and is shared between tasks.
|
|
It should be backed by a PersistentVolumeClaim or VolumeClaimTemplate.
|
|
- name: docker-credentials
|
|
description: |
|
|
This workspace contains the docker config.json for authenticating to Harbor.
|
|
It should be backed by a Secret containing .dockerconfigjson
|
|
|
|
tasks:
|
|
- name: fetch-repository
|
|
taskRef:
|
|
name: git-clone
|
|
workspaces:
|
|
- name: output
|
|
workspace: shared-workspace
|
|
params:
|
|
- name: url
|
|
value: $(params.git-url)
|
|
- name: revision
|
|
value: $(params.git-revision)
|
|
- name: deleteExisting
|
|
value: "true"
|
|
|
|
- name: build-and-push
|
|
taskRef:
|
|
name: kaniko-build
|
|
runAfter:
|
|
- fetch-repository
|
|
workspaces:
|
|
- name: source
|
|
workspace: shared-workspace
|
|
- name: dockerconfig
|
|
workspace: docker-credentials
|
|
params:
|
|
- name: IMAGE
|
|
value: "$(params.image-name):$(params.image-tag)"
|
|
- name: DOCKERFILE
|
|
value: $(params.dockerfile)
|
|
- name: CONTEXT
|
|
value: $(params.context)
|
|
- name: EXTRA_ARGS
|
|
value:
|
|
- --skip-tls-verify
|
|
- --verbosity=info
|
|
- --skip-unused-stages=true
|
|
|
|
results:
|
|
- name: IMAGE_DIGEST
|
|
description: The digest of the built image
|
|
value: $(tasks.build-and-push.results.IMAGE_DIGEST)
|
|
- name: IMAGE_URL
|
|
description: The URL of the built image
|
|
value: $(tasks.build-and-push.results.IMAGE_URL)
|