53 lines
1.4 KiB
YAML
53 lines
1.4 KiB
YAML
apiVersion: tekton.dev/v1beta1
|
|
kind: Task
|
|
metadata:
|
|
name: build-docker-image
|
|
namespace: tekton-demo
|
|
spec:
|
|
workspaces:
|
|
- name: docker-config
|
|
|
|
params:
|
|
- name: git-url
|
|
type: string
|
|
description: Git repository URL
|
|
- name: git-revision
|
|
type: string
|
|
default: "main"
|
|
description: Git branch or commit
|
|
- name: image-url
|
|
type: string
|
|
# description: 최종 Docker 이미지 URL (예: harbor.icurfer.com/open/tekton-demo:latest)
|
|
volumes:
|
|
- name: harbor-dockerconfig
|
|
secret:
|
|
secretName: harbor-dockerconfig # Harbor Docker config secret name
|
|
|
|
steps:
|
|
# 1. Git Clone
|
|
- name: git-clone
|
|
image: alpine/git
|
|
script: |
|
|
#!/bin/sh
|
|
set -e
|
|
echo "==== [INFO] Git 저장소 클론 ===="
|
|
git clone $(params.git-url) /workspace/source
|
|
cd /workspace/source
|
|
git checkout $(params.git-revision)
|
|
echo "==== [INFO] Git checkout 완료 ===="
|
|
|
|
|
|
# Kaniko Build & Push
|
|
- name: build-and-push
|
|
image: gcr.io/kaniko-project/executor:latest
|
|
volumeMounts:
|
|
- name: harbor-dockerconfig
|
|
mountPath: /kaniko/.docker/config.json
|
|
subPath: .dockerconfigjson
|
|
readOnly: true
|
|
args:
|
|
- --dockerfile=/workspace/source/Dockerfile
|
|
- --context=/workspace/source
|
|
- --destination=$(params.image-url)
|
|
- --insecure
|
|
|