init
This commit is contained in:
parent
1bc9347b7b
commit
b48019e360
@ -23,7 +23,7 @@ spec:
|
|||||||
default: ./Dockerfile
|
default: ./Dockerfile
|
||||||
|
|
||||||
- name: context
|
- name: context
|
||||||
description: Build context path
|
description: Build context path (relative to subdirectory)
|
||||||
type: string
|
type: string
|
||||||
default: .
|
default: .
|
||||||
|
|
||||||
@ -40,13 +40,13 @@ spec:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build-and-push
|
- name: build-and-push
|
||||||
image: alpine:3.18
|
image: gcr.io/kaniko-project/executor:v1.23.2
|
||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
env:
|
env:
|
||||||
- name: DOCKER_CONFIG
|
- name: DOCKER_CONFIG
|
||||||
value: /tekton/home/.docker/
|
value: /tekton/home/.docker
|
||||||
script: |
|
script: |
|
||||||
#!/bin/sh
|
#!/busybox/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
if [ -n "$(params.subdirectory)" ]; then
|
||||||
@ -57,14 +57,12 @@ spec:
|
|||||||
|
|
||||||
IMAGE="$(params.imageName):$(params.tag)"
|
IMAGE="$(params.imageName):$(params.tag)"
|
||||||
echo "📦 Using image: $IMAGE"
|
echo "📦 Using image: $IMAGE"
|
||||||
echo -n "$IMAGE" > /tekton/results/imageUrl
|
|
||||||
|
|
||||||
echo "🔐 Loading Docker credentials..."
|
|
||||||
USERNAME=$(cat /workspace/docker-auth/username)
|
USERNAME=$(cat /workspace/docker-auth/username)
|
||||||
PASSWORD=$(cat /workspace/docker-auth/password)
|
PASSWORD=$(cat /workspace/docker-auth/password)
|
||||||
REGISTRY=$(echo "$IMAGE" | cut -d/ -f1)
|
REGISTRY=$(echo "$IMAGE" | cut -d/ -f1)
|
||||||
|
|
||||||
echo "📝 Writing Docker config for $REGISTRY"
|
echo "🔐 Creating Docker config for $REGISTRY"
|
||||||
mkdir -p /tekton/home/.docker
|
mkdir -p /tekton/home/.docker
|
||||||
cat > /tekton/home/.docker/config.json <<EOF
|
cat > /tekton/home/.docker/config.json <<EOF
|
||||||
{
|
{
|
||||||
@ -78,14 +76,14 @@ spec:
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "📥 Installing Kaniko executor..."
|
echo "🚀 Building and pushing with Kaniko..."
|
||||||
wget -q -O /kaniko.tar.gz https://github.com/GoogleContainerTools/kaniko/releases/download/v1.17.0/executor-linux-amd64.tar.gz
|
/kaniko/executor \
|
||||||
tar -xzf /kaniko.tar.gz -C /usr/local/bin
|
|
||||||
chmod +x /usr/local/bin/executor
|
|
||||||
|
|
||||||
echo "🚀 Building and pushing image with Kaniko..."
|
|
||||||
executor \
|
|
||||||
--dockerfile=$(params.dockerfile) \
|
--dockerfile=$(params.dockerfile) \
|
||||||
--context="$(params.context)" \
|
--context=$(params.context) \
|
||||||
--destination="$IMAGE" \
|
--destination="$IMAGE" \
|
||||||
--skip-tls-verify
|
--skip-tls-verify \
|
||||||
|
--reproducible \
|
||||||
|
--verbosity=info
|
||||||
|
|
||||||
|
echo "✅ Build complete. Saving image URL..."
|
||||||
|
echo -n "$IMAGE" > /tekton/results/imageUrl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user