This commit is contained in:
병준 박 2025-04-12 13:41:04 +00:00
parent d9064d1343
commit 296edaeb47

View File

@ -10,7 +10,7 @@ spec:
default: ""
- name: imageName
description: Base image name with registry (e.g. registry.unbox-x.net/unbox-x-aisi-cron-app)
description: Base image name with registry (e.g. docker.unbox-x.net/registry/unbox-x-aisi-cron-app)
type: string
- name: tag
@ -39,54 +39,43 @@ spec:
description: Final pushed image URL with tag (e.g. registry/app:v0.2.0)
steps:
- name: build-and-push
# 🔐 인증 정보 생성
- name: write-docker-config
image: alpine:3.21.3
workingDir: /workspace/source
env:
- name: DOCKER_CONFIG
value: /tekton/home/.docker
script: |
#!/bin/sh
set -e
echo "📦 Installing curl and tar..."
apk add --no-cache curl tar
if [ -n "$(params.subdirectory)" ]; then
cd "$(params.subdirectory)"
fi
IMAGE="$(params.imageName):$(params.tag)"
echo "📦 Using image: $IMAGE"
echo -n "$IMAGE" > /tekton/results/imageUrl
USERNAME=$(cat /workspace/docker-auth/username)
PASSWORD=$(cat /workspace/docker-auth/password)
REGISTRY=$(echo "$IMAGE" | cut -d/ -f1)
echo "📦 Using image: $IMAGE"
echo -n "$IMAGE" > /tekton/results/imageUrl
echo "🔐 Writing Docker config for $REGISTRY..."
mkdir -p "$DOCKER_CONFIG"
cat > "$DOCKER_CONFIG/config.json" <<EOF
{
"auths": {
"$REGISTRY": {
"auth": "$(echo -n "$USERNAME:$PASSWORD" | base64)"
}
}
}
EOF
mkdir -p /tekton/home/.docker
echo "{\"auths\": {\"$REGISTRY\": {\"auth\": \"$(echo -n "$USERNAME:$PASSWORD" | base64)"}}}" \
> /tekton/home/.docker/config.json
echo "📥 Downloading Kaniko executor..."
curl -sSL -o /kaniko.tar.gz https://github.com/GoogleContainerTools/kaniko/releases/download/v1.23.2/executor-linux-amd64.tar.gz
mkdir -p /kaniko && tar -xzf /kaniko.tar.gz -C /kaniko
chmod +x /kaniko/executor
echo "🚀 Building and pushing image..."
/kaniko/executor \
--dockerfile="$(params.dockerfile)" \
--context="$(params.context)" \
--destination="$IMAGE" \
--skip-tls-verify \
--reproducible \
--verbosity=info
# 🏗️ Kaniko 공식 이미지 실행
- name: kaniko-build
image: gcr.io/kaniko-project/executor:v1.23.2
workingDir: /workspace/source
env:
- name: DOCKER_CONFIG
value: /tekton/home/.docker
args:
- --dockerfile=$(params.subdirectory)/$(params.dockerfile)
- --context=$(params.subdirectory)/$(params.context)
- --destination=$(params.imageName):$(params.tag)
- --skip-tls-verify
- --reproducible
- --verbosity=info