diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-06 21:07:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-06 21:07:05 +0300 |
commit | 2644e59eb5a3a976d445a08727f41428647fdbec (patch) | |
tree | 38c819b7ba781e88b6cdd9a05eff53c78c4a9486 /lib/gitlab | |
parent | 31e17bdaabfc530fa0358f4a86800865011a0b23 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml b/lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml index d7a6104082d..4c89497fa97 100644 --- a/lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml @@ -46,13 +46,30 @@ kaniko-build: # Write credentials to access Gitlab Container Registry within the runner/ci - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json # Build and push the container. To disable push add --no-push - - DOCKERFILE_PATH=${DOCKERFILE_PATH:-"$KANIKO_BUILD_CONTEXT/Dockerfile"} + # Both Dockerfile and Containerfile are supported. For retrocompatibility, if both files are present, Dockerfile will be used. + - | + if [ -z "$DOCKERFILE_PATH" ]; then + if [ -f "$KANIKO_BUILD_CONTEXT/Dockerfile" ]; then + DOCKERFILE_PATH="$KANIKO_BUILD_CONTEXT/Dockerfile" + elif [ -n "$CONTAINERFILE_PATH" ]; then + DOCKERFILE_PATH="$CONTAINERFILE_PATH" + elif [ -f "$KANIKO_BUILD_CONTEXT/Containerfile" ]; then + DOCKERFILE_PATH="$KANIKO_BUILD_CONTEXT/Containerfile" + else \ + echo "No suitable configuration for the build context have been found. Please check your configuration." + exit 1 + fi + fi + - echo $DOCKERFILE_PATH - /kaniko/executor --context $KANIKO_BUILD_CONTEXT --dockerfile $DOCKERFILE_PATH --destination $IMAGE_TAG $KANIKO_ARGS - # Run this job in a branch/tag where a Dockerfile exists + # Run this job in a branch/tag where a Containerfile/Dockerfile exists rules: - exists: + - Containerfile - Dockerfile - # custom Dockerfile path + # custom Containerfile/Dockerfile path + # If both variables are set, DOCKERFILE_PATH will be used - if: $DOCKERFILE_PATH + - if: $CONTAINERFILE_PATH # custom build context without an explicit Dockerfile path - if: $KANIKO_BUILD_CONTEXT != $CI_PROJECT_DIR |