add setup-kaniko-auth.sh
This commit is contained in:
parent
5833c1a1f2
commit
054533f574
@ -13,7 +13,9 @@ FROM alpine:latest AS prod
|
||||
|
||||
WORKDIR /src/
|
||||
|
||||
RUN apk --no-cache add ca-certificates git && mkdir -pv /kaniko/
|
||||
COPY --from=builder /src/go/bin/executor /kaniko/
|
||||
COPY setup-kaniko-auth.sh /kaniko/setup-kaniko-auth.sh
|
||||
RUN apk --no-cache add ca-certificates git && \
|
||||
chmod +x /kaniko/setup-kaniko-auth.sh
|
||||
|
||||
ENTRYPOINT ["/bin/sh"]
|
||||
|
||||
25
oci/base/alpine-image-builder/setup-kaniko-auth.sh
Normal file
25
oci/base/alpine-image-builder/setup-kaniko-auth.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
REGISTRY_ADDR=$1
|
||||
REGISTRY_REPO_USER=$2
|
||||
REGISTRY_REPO_PASSWORD=$3
|
||||
DEBUG=${4:-false}
|
||||
|
||||
check_non_empty() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: $2 must be provided."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_non_empty "$REGISTRY_ADDR" "Registry address"
|
||||
check_non_empty "$REGISTRY_REPO_USER" "Registry username"
|
||||
check_non_empty "$REGISTRY_REPO_PASSWORD" "Registry password"
|
||||
|
||||
mkdir -p /kaniko/.docker
|
||||
AUTH=$(echo -n "${REGISTRY_REPO_USER}:${REGISTRY_REPO_PASSWORD}" | base64)
|
||||
echo "{\"auths\":{\"https://${REGISTRY_ADDR}/v1/\":{\"auth\":\"${AUTH}\"}}}" > /kaniko/.docker/config.json
|
||||
|
||||
if [ "$DEBUG" = "true" ]; then
|
||||
cat /kaniko/.docker/config.json
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user