Skip to content
Snippets Groups Projects
Commit afd89ac5 authored by Jan Hartig's avatar Jan Hartig
Browse files

Better kaniko build caching

parent 5437eb2b
No related branches found
No related tags found
1 merge request!3Resolve "Better Caching"
.build_with_kaniko:
build_with_kaniko:
stage: build
variables:
http_proxy: $http_proxy
https_proxy: $https_proxy
no_proxy: $no_proxy
image:
name: gcr.io/kaniko-project/executor:v1.9.0-debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD | base64 -w 0)\"},\"$HARBOR_REGISTRY\":{\"auth\":\"$(echo -n $HARBOR_REGISTRY_USER:$HARBOR_REGISTRY_PASSWORD | base64 -w 0)\"}}}" > /kaniko/.docker/config.json
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag="latest"
......@@ -17,14 +14,18 @@
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi
- /kaniko/executor
--cache=true --cache-copy-layers=true --cache-ttl=168h --compressed-caching=false
--cache=true
--cache-copy-layers=true
--compressed-caching=false
--cache-repo "$CI_REGISTRY_IMAGE/cache"
--registry-certificate=$HARBOR_REGISTRY=$HARBOR_CERT
--context "${CI_PROJECT_DIR}"
--build-arg http_proxy=$http_proxy
--build-arg https_proxy=$https_proxy
--build-arg no_proxy=$no_proxy
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "$CI_REGISTRY_IMAGE:${tag}"
"$EXTRA_ARGS"
--destination "$HARBOR_REGISTRY_IMAGE:${tag}"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
exists:
......@@ -32,17 +33,3 @@
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+$/'
exists:
- Dockerfile
build-for-gitlab-project-registry:
extends: .build_with_kaniko
environment:
# Since there are no CI CD Variables with this scope, the project defaults are used to push to this projects docker registry
name: push-to-gitlab-project-registry
build-for-hpc-harbor:
extends: .build_with_kaniko
stage: build
# This causes CI CD Variables to be taken from GitLab Project definition for variable scope "push-to-hpc-harbor",
# which overrides CI_REGISTRY, CI_REGISTRY_IMAGE, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD
environment:
name: push-to-hpc-harbor
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment