Commit d1fb9295 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch 'feat/add_kaniko_context_dir_selection_option_in_kaniko_build_job' into 'master'

Enable kaniko custom build context

See merge request gitlab-org/gitlab!75530
parents a350fd7d 04e5001f
...@@ -11,6 +11,7 @@ kaniko-build: ...@@ -11,6 +11,7 @@ kaniko-build:
# Additional options for Kaniko executor. # Additional options for Kaniko executor.
# For more details see https://github.com/GoogleContainerTools/kaniko/blob/master/README.md#additional-flags # For more details see https://github.com/GoogleContainerTools/kaniko/blob/master/README.md#additional-flags
KANIKO_ARGS: "" KANIKO_ARGS: ""
KANIKO_BUILD_CONTEXT: $CI_PROJECT_DIR
stage: build stage: build
image: image:
# For latest releases see https://github.com/GoogleContainerTools/kaniko/releases # For latest releases see https://github.com/GoogleContainerTools/kaniko/releases
...@@ -40,8 +41,13 @@ kaniko-build: ...@@ -40,8 +41,13 @@ kaniko-build:
# Write credentials to access Gitlab Container Registry within the runner/ci # 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 - 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 # Build and push the container. To disable push add --no-push
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$VERSION $KANIKO_ARGS - DOCKERFILE_PATH=${DOCKERFILE_PATH:-"$KANIKO_BUILD_CONTEXT/Dockerfile"}
- /kaniko/executor --context $KANIKO_BUILD_CONTEXT --dockerfile $DOCKERFILE_PATH --destination $CI_REGISTRY_IMAGE:$VERSION $KANIKO_ARGS
# Run this job in a branch/tag where a Dockerfile exists # Run this job in a branch/tag where a Dockerfile exists
rules: rules:
- exists: - exists:
- Dockerfile - Dockerfile
# custom Dockerfile path
- if: $DOCKERFILE_PATH
# custom build context without an explicit Dockerfile path
- if: $KANIKO_BUILD_CONTEXT != $CI_PROJECT_DIR
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment