Skip to content
Snippets Groups Projects
Commit bd5c77ea authored by Daniel Dehennin's avatar Daniel Dehennin
Browse files

feat(docker): .build-docker-image must accept kaniko arguments

Some users may requires to pass kaniko arguments to set, for example,
some build args required by the Dockerfile.

* templates/Docker.yaml: add `KANIKO_ARGS` optional variable
  overridable by users and pass it to executor command line.
parent b010f0d6
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@
# - to `Dockerfile.${IMAGE_NAME}` if the file exists
# - to `Dockerfile` if the file exists
# - `IMAGE_TAG`: defaults to `git-${CI_COMMIT_SHORT_SHA}`
# - `KANIKO_ARGS`: arguments to pass to kaniko executor command, empty by default
#
# USED CI VARIABLES
# =================
......@@ -44,6 +45,8 @@
image:
name: gcr.io/kaniko-project/executor:v1.7.0-debug
entrypoint: [""]
variables:
KANIKO_ARGS: ''
script:
- export IMAGE_NAME=${IMAGE_NAME:-${CI_JOB_NAME%-docker-build*}}
- test -f Dockerfile.${IMAGE_NAME} && export DOCKERFILE=${DOCKERFILE:-Dockerfile.${IMAGE_NAME}} || true
......@@ -51,7 +54,7 @@
- export IMAGE_TAG=${IMAGE_TAG:-git-${CI_COMMIT_SHORT_SHA}}
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context ${CI_PROJECT_DIR} --dockerfile $CI_PROJECT_DIR/${DOCKERFILE} --destination ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG}
- /kaniko/executor ${KANIKO_ARGS} --context ${CI_PROJECT_DIR} --dockerfile $CI_PROJECT_DIR/${DOCKERFILE} --destination ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG}
# Define `.tag-docker-image` template used by `*-docker-tag` jobs
# It tag the `${IMAGE_NAME}:${SOURCE_TAG}` with the tag `${IMAGE_TAG}`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment