From d48f9cdabbc93978c8af0889e651ed98429e3216 Mon Sep 17 00:00:00 2001 From: BAK BYEONG JUN Date: Sat, 12 Apr 2025 15:22:18 +0000 Subject: [PATCH] init --- tasks/docker-registry/task.yaml | 87 +++++++++++++-------------------- 1 file changed, 33 insertions(+), 54 deletions(-) diff --git a/tasks/docker-registry/task.yaml b/tasks/docker-registry/task.yaml index 2cbf99f..1a969c0 100644 --- a/tasks/docker-registry/task.yaml +++ b/tasks/docker-registry/task.yaml @@ -6,58 +6,34 @@ spec: params: - name: subdirectory type: string + description: Subdirectory within the repo where the source code is located default: "" - description: Subdirectory within the repo where the Dockerfile/context reside - - name: imageName + description: Base image name with registry type: string - description: Full image name (e.g. docker.unbox-x.net/registry/my-app) - - name: tag + description: Version tag to apply to the image type: string - description: Version tag (e.g. v1.0.0) - - name: dockerfile + description: Path to Dockerfile type: string default: ./Dockerfile - description: Path to Dockerfile (relative to subdirectory) - - name: context + description: Build context path (relative to subdirectory) type: string default: . - description: Build context (relative to subdirectory) - workspaces: - name: source description: Source code workspace - - name: docker-auth - description: Docker registry secret (username/password) - + description: Docker registry credentials (username + password) - name: pypi-auth - description: PyPI registry secret (username/password) - + description: PyPI registry credentials (username + password) results: - name: imageUrl description: Final pushed image URL with tag - - volumes: - - name: env - emptyDir: {} - steps: - - name: write-pypi-env - image: alpine:3.21.3 - script: | - #!/bin/sh - set -e - mkdir -p /custom-env - echo "PYPI_USERNAME=$(cat /workspace/pypi-auth/username)" > /custom-env/.env - echo "PYPI_PASSWORD=$(cat /workspace/pypi-auth/password)" >> /custom-env/.env - volumeMounts: - - name: env - mountPath: /custom-env - + # πŸ” 인증 정보 생성 - name: write-docker-config image: alpine:3.21.3 workingDir: /workspace/source @@ -74,8 +50,10 @@ spec: 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 /tekton/home/.docker cat > /tekton/home/.docker/config.json < /tekton/home/pypi-auth.env + echo "PYPI_PASSWORD=$(cat /workspace/pypi-auth/password)" >> /tekton/home/pypi-auth.env + + # πŸ—οΈ Kaniko 곡식 이미지 μ‹€ν–‰ - name: kaniko-build image: gcr.io/kaniko-project/executor:v1.23.2 workingDir: /workspace/source - command: ["/bin/sh"] - args: - - -c - - | - set -e - . /custom-env/.env - - /kaniko/executor \ - --dockerfile=$(params.subdirectory)/$(params.dockerfile) \ - --context=$(params.subdirectory)/$(params.context) \ - --destination=$(params.imageName):$(params.tag) \ - --build-arg=PYPI_USERNAME=$PYPI_USERNAME \ - --build-arg=PYPI_PASSWORD=$PYPI_PASSWORD \ - --skip-tls-verify \ - --reproducible \ - --verbosity=info env: - name: DOCKER_CONFIG value: /tekton/home/.docker - volumeMounts: - - name: env - mountPath: /custom-env \ No newline at end of file + script: | + #!/bin/sh + set -e + + # PyPI 인증 정보 λ‘œλ“œ + source /tekton/home/pypi-auth.env + + # Kaniko λΉŒλ“œ μ‹€ν–‰ + /kaniko/executor \ + --dockerfile=$(params.subdirectory)/$(params.dockerfile) \ + --context=$(params.subdirectory)/$(params.context) \ + --destination=$(params.imageName):$(params.tag) \ + --skip-tls-verify \ + --reproducible \ + --verbosity=info \ + --build-arg=PYPI_USERNAME=$PYPI_USERNAME \ + --build-arg=PYPI_PASSWORD=$PYPI_PASSWORD \ No newline at end of file