diff --git a/kaniko/Dockerfile b/kaniko/Dockerfile index a2b550c..1eb5e78 100644 --- a/kaniko/Dockerfile +++ b/kaniko/Dockerfile @@ -4,6 +4,8 @@ FROM gcr.io/kaniko-project/executor:v1.7.0-debug AS kaniko-src # https://github.com/GoogleContainerTools/kaniko/issues/960#issuecomment-573160390 RUN cp -r /kaniko /kaniko-dist +FROM gcr.io/go-containerregistry/crane as crane + FROM alpine/git # See https://github.com/GoogleContainerTools/kaniko/blob/master/deploy/Dockerfile#L65-L70 @@ -17,4 +19,10 @@ ENV SSL_CERT_DIR=/kaniko/ssl/certs ENV DOCKER_CONFIG /kaniko/.docker/ ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json -ENTRYPOINT ["/kaniko/executor"] +RUN apk add --no-cache jq +COPY --from=crane /ko-app/crane /usr/local/bin/crane + +# Copy entry point +COPY entry_point.sh /root/entry_point.sh + +ENTRYPOINT ["/root/entry_point.sh"] diff --git a/kaniko/entry_point.sh b/kaniko/entry_point.sh new file mode 100644 index 0000000..ac19900 --- /dev/null +++ b/kaniko/entry_point.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +if [ -z "$BUILD_IMAGE_NO_MESSAGE" ]; then + echo "You are using a GitLab CI build-image with kaniko and crane" + echo "You can suppress this message by setting BUILD_IMAGE_NO_MESSAGE" + + /kaniko/executor version + echo "Crane version: $(crane version)" +fi + +if [ -z "$BUILD_IMAGE_NO_AUTO_LOGIN" ]; then + if [ -n "$CI_REGISTRY_USER" ] && [ -n "$CI_REGISTRY_PASSWORD" ] && [ -n "$CI_REGISTRY" ]; then + echo "Logging into GitLab CI registry ($CI_REGISTRY)" + echo "You can suppress this behavior by setting BUILD_IMAGE_NO_AUTO_LOGIN" + crane auth login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY" + fi +fi + +if [ -z "$1" ]; then + sh +else + exec "$@" +fi