diff --git a/kaniko.sh b/kaniko.sh index af113f0..89976a0 100755 --- a/kaniko.sh +++ b/kaniko.sh @@ -16,6 +16,7 @@ docker run -v ~/conf:/root/conf -v ~/.docker:/root/.docker -v "$(pwd)":/workspac -e IMAGE_TAG=${IMAGE_TAG} \ -e NAMESPACE=${NAMESPACE} \ -e REGISTRY="${REGISTRY}" \ + -e DOCKER_AUTH_CONFIG="/root/.docker/config-gitlab.json" \ -e CI_COMMIT_REF_NAME="${CI_COMMIT_REF_NAME}" \ -e CI_COMMIT_SHA="$(git show --format="%H" --no-patch)" \ -e CI_COMMIT_TIMESTAMP="$(git show --format="%aI" --no-patch)" \ diff --git a/scripts/dockerfile-functions.sh b/scripts/dockerfile-functions.sh index 11f98ed..1a292ee 100644 --- a/scripts/dockerfile-functions.sh +++ b/scripts/dockerfile-functions.sh @@ -1,5 +1,5 @@ ##!/bin/sh -echo "docker build setup $0" +echo "docker build setup" TXT_HI="\e[93m" && TXT_CLEAR="\e[0m" diff --git a/scripts/kaniko-functions.sh b/scripts/kaniko-functions.sh index 9213b8a..e24353a 100644 --- a/scripts/kaniko-functions.sh +++ b/scripts/kaniko-functions.sh @@ -3,7 +3,6 @@ KANIKO_ARGS=${KANIKO_ARGS:-'--cache=true --cache-copy-layers=true'} REGISTRY="${REGISTRY:-registry.npohosting.nl}" NAMESPACE=${NAMESPACE:-poms} DOCKER_BUILD_ARGS=${DOCKER_BUILD_ARGS:-} # Uses eval, when overriding escape whitespace: '--build-arg\ "FOO=BAR"' -DOCKER_AUTH_CONFIG_FILE=$HOME/.docker/config-gitlab.json if ! type os_app_name &> /dev/null; then @@ -14,12 +13,28 @@ fi # param: directory to execute for run_kaniko() { echo "Using build args $DOCKER_BUILD_ARGS" - setup_kaniko "$DOCKER_AUTH_CONFIG_FILE" + setup_kaniko kaniko_execute "$@" store_image_version } +echo "Defining function setup_kaniko" +# Just arranges authentication by copying the config.json file to right spot +setup_kaniko() { + mkdir -p /kaniko/.docker + incoming="$DOCKER_AUTH_CONFIG" + if [ -e "$incoming" ] ; then + echo "Copying $incoming to /kaniko/.docker/config.json" + echo "lines: $(wc -l $incoming)" + cp $incoming /kaniko/.docker/config.json + else + echo "No incoming docker configuration file '$incoming'" + fi +} + + + echo "Defining function kaniko_execute" # $1: is the directory to run for, defaults to DOCKER_DIR # $2: is a version to build defaults to PROJECT_VERSION diff --git a/scripts/kaniko-gitlab-functions.sh b/scripts/kaniko-gitlab-functions.sh index 1a18035..871d5b9 100644 --- a/scripts/kaniko-gitlab-functions.sh +++ b/scripts/kaniko-gitlab-functions.sh @@ -18,32 +18,11 @@ else echo "No job.env in $(pwd)" fi - - # shellcheck source=${KANIKO_SCRIPTS}kaniko-functions.sh if ! type os_app_name &> /dev/null ; then . "$KANIKO_SCRIPTS"kaniko-functions.sh fi -echo "Defining function setup_kaniko" -# Just arranges authentication by copying the config.json file to right spot -# $1 ~/.docker/config.json file. Defaults to DOCKER_AUTH_CONFIG -setup_kaniko() { - mkdir -p /kaniko/.docker - incoming="$1" - if [ -z "$incoming" ] ; then - echo "No incoming kaniko config file. Using $DOCKER_AUTH_CONFIG" - incoming="$DOCKER_AUTH_CONFIG" - fi - if [ -e "$incoming" ] ; then - echo "Copying $incoming to /kaniko/.docker/config.json" - echo "lines: $(wc -l $incoming)" - cp $incoming /kaniko/.docker/config.json - else - echo "No incoming docker configuration file '$incoming'" - fi -} - # Stores relevant variables determined by get_artifact_versions in job.env diff --git a/scripts/script.sh b/scripts/script.sh index 524a5df..902bfe7 100644 --- a/scripts/script.sh +++ b/scripts/script.sh @@ -11,7 +11,6 @@ if [ "$TRACE" = 'true' ]; then set -x fi -echo Using registry ${REGISTRY} . "$KANIKO_SCRIPTS"kaniko-gitlab-functions.sh . "$KANIKO_SCRIPTS"kaniko-maven.sh