From faff9368eddaacf6434eebf2d282c3d66f0ef887 Mon Sep 17 00:00:00 2001 From: Mark <mark@openappstack.net> Date: Fri, 8 Nov 2019 15:47:11 +0100 Subject: [PATCH] Add build arg to kaniko image --- .gitlab/ci_templates/kaniko.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci_templates/kaniko.yml b/.gitlab/ci_templates/kaniko.yml index 9ea7d2967..7165ca409 100644 --- a/.gitlab/ci_templates/kaniko.yml +++ b/.gitlab/ci_templates/kaniko.yml @@ -8,6 +8,13 @@ # # - KANIKO_CONTEXT: The subdir which holds the Dockerfile, leave unset if # the Dockerfile is located at root level of the project. +# +# - KANIKO_EXTEND_BASEIMAGE: Name of an image that is build in the same +# pipeline and is being used by your dockerfile as a baseimage. +# You need to specify the argument `baseimage` in your dockerfile and use +# this argument in the `FROM` instruction. +# see [how to use build arguments](https://docs.docker.com/engine/reference/builder/#arg) +# for more information. .kaniko_build: stage: build image: @@ -18,4 +25,5 @@ script: - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - if [ -n "${KANIKO_BUILD_IMAGENAME}" ]; then export IMAGENAME="/${KANIKO_BUILD_IMAGENAME}"; fi - - /kaniko/executor --context ${CI_PROJECT_DIR}/${KANIKO_CONTEXT:-.} --dockerfile ${CI_PROJECT_DIR}/${KANIKO_CONTEXT:-.}/Dockerfile --destination ${CI_REGISTRY_IMAGE}${IMAGENAME}:${CI_COMMIT_REF_NAME} + - if [ -n "${KANIKO_EXTEND_BASEIMAGE}" ]; then export BASEIMAGE="--build-arg baseimage=${CI_REGISTRY_IMAGE}/${KANIKO_EXTEND_BASEIMAGE}:${CI_COMMIT_REF_NAME}"; fi + - /kaniko/executor --context ${CI_PROJECT_DIR}/${KANIKO_CONTEXT:-.} --dockerfile ${CI_PROJECT_DIR}/${KANIKO_CONTEXT:-.}/Dockerfile --destination ${CI_REGISTRY_IMAGE}${IMAGENAME}:${CI_COMMIT_REF_NAME} ${BASEIMAGE} -- GitLab