This commit is contained in:
병준 박 2025-04-12 16:57:04 +00:00
parent f66c1c4cd6
commit f7b9e96ab4

View File

@ -8,32 +8,40 @@ spec:
type: string type: string
description: Subdirectory within the repo where the source code is located description: Subdirectory within the repo where the source code is located
default: "" default: ""
- name: imageName - name: imageName
description: Base image name with registry description: Base image name with registry (e.g. docker.unbox-x.net/registry/unbox-x-aisi-cron-app)
type: string type: string
- name: tag - name: tag
description: Version tag to apply to the image description: Version tag to apply to the image (e.g. v0.2.0)
type: string type: string
- name: dockerfile - name: dockerfile
description: Path to Dockerfile description: Path to Dockerfile
type: string type: string
default: ./Dockerfile default: ./Dockerfile
- name: context - name: context
description: Build context path (relative to subdirectory) description: Build context path (relative to subdirectory)
type: string type: string
default: . default: .
workspaces: workspaces:
- name: source - name: source
description: Source code workspace description: Source code workspace
- name: docker-auth - name: docker-auth
description: Docker registry credentials (username + password) description: Docker registry credentials (username + password)
- name: pypi-auth - name: pypi-auth
description: PyPI registry credentials (username + password) description: PyPI credentials (username + password)
results: results:
- name: imageUrl - name: imageUrl
description: Final pushed image URL with tag description: Final pushed image URL with tag (e.g. registry/app:v0.2.0)
steps: steps:
# 🔐 인증 정보 생성
- name: write-docker-config - name: write-docker-config
image: alpine:3.21.3 image: alpine:3.21.3
workingDir: /workspace/source workingDir: /workspace/source
@ -55,48 +63,33 @@ spec:
echo "🔐 Writing Docker config for $REGISTRY..." echo "🔐 Writing Docker config for $REGISTRY..."
mkdir -p /tekton/home/.docker mkdir -p /tekton/home/.docker
cat > /tekton/home/.docker/config.json <<EOF echo "{\"auths\": {\"$REGISTRY\": {\"auth\": \"$(echo -n "$USERNAME:$PASSWORD" | base64)"}}}" \
{ > /tekton/home/.docker/config.json
"auths": {
"$REGISTRY": {
"auth": "$(echo -n "$USERNAME:$PASSWORD" | base64)"
}
}
}
EOF
# PyPI 인증 정보 변수 정의
echo "🔐 Setting PyPI auth env..."
PYPI_USERNAME=$(cat /workspace/pypi-auth/username)
PYPI_PASSWORD=$(cat /workspace/pypi-auth/password)
echo "export PYPI_USERNAME=$PYPI_USERNAME" > /tekton/home/pypi-auth.env
echo "export PYPI_PASSWORD=$PYPI_PASSWORD" >> /tekton/home/pypi-auth.env
# 🏗️ Kaniko 공식 이미지 실행
- name: kaniko-build - name: kaniko-build
image: gcr.io/kaniko-project/executor:v1.23.2 image: bitnami/kaniko:1.23.2
workingDir: /workspace/source workingDir: /workspace/source
env: env:
- name: DOCKER_CONFIG - name: DOCKER_CONFIG
value: /tekton/home/.docker value: /tekton/home/.docker
- name: PYPI_USERNAME script: |
valueFrom: #!/bin/sh
configMapKeyRef: set -e
name: pypi-auth-config
key: username if [ -n "$(params.subdirectory)" ]; then
optional: true cd "$(params.subdirectory)"
- name: PYPI_PASSWORD fi
valueFrom:
configMapKeyRef: PYPI_USERNAME=$(cat /workspace/pypi-auth/username)
name: pypi-auth-config PYPI_PASSWORD=$(cat /workspace/pypi-auth/password)
key: password
optional: true echo "🚀 Running bitnami/kaniko build..."
args: /kaniko/executor \
- --dockerfile=$(params.subdirectory)/$(params.dockerfile) --dockerfile=$(params.dockerfile) \
- --context=$(params.subdirectory)/$(params.context) --context=$(params.context) \
- --destination=$(params.imageName):$(params.tag) --destination=$(params.imageName):$(params.tag) \
- --skip-tls-verify --skip-tls-verify \
- --reproducible --reproducible \
- --verbosity=debug --verbosity=info \
- --build-arg=PYPI_USERNAME=$(env PYPI_USERNAME) --build-arg PYPI_USERNAME=$PYPI_USERNAME \
- --build-arg=PYPI_PASSWORD=$(env PYPI_PASSWORD) --build-arg PYPI_PASSWORD=$PYPI_PASSWORD