Skip to content
Snippets Groups Projects
Commit a7f1da9b authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'fix-cache-repo' into 'master'

fix(kaniko cache): add --cache-repo option

See merge request to-be-continuous/docker!78
parents 95245ba4 7d4a1946
Branches
Tags
No related merge requests found
......@@ -384,7 +384,7 @@ stages:
function create_kaniko_cache_dir() {
# create cache directory if needed
mkdir -p "$KANIKO_CACHE_DIR"
mkdir -p "${CI_PROJECT_DIR}/.cache"
}
function init_workspace() {
......@@ -416,6 +416,7 @@ stages:
function run_build_kaniko() {
docker_image=$1
kaniko_registry_repository=$(echo "$DOCKER_SNAPSHOT_IMAGE" | cut -d: -f1)
shift
if [[ -n "$DOCKER_REGISTRY_MIRROR" ]]
then
......@@ -423,9 +424,9 @@ stages:
kaniko_registry_mirror_option="--registry-mirror $(echo ${DOCKER_REGISTRY_MIRROR} | sed "s|^https*://||")"
fi
log_info "Build & deploy image $docker_image"
log_info "Kaniko command: /kaniko/executor --context $(docker_context_path) --dockerfile $DOCKER_FILE --destination $docker_image --cache --cache-dir=$KANIKO_CACHE_DIR --verbosity $DOCKER_KANIKO_VERBOSITY $kaniko_registry_mirror_option $DOCKER_METADATA $DOCKER_BUILD_ARGS $*"
log_info "Kaniko command: /kaniko/executor --context $(docker_context_path) --dockerfile $DOCKER_FILE --destination $docker_image --cache --cache-dir=${CI_PROJECT_DIR}/.cache --cache-repo="$kaniko_registry_repository" --verbosity $DOCKER_KANIKO_VERBOSITY $kaniko_registry_mirror_option $DOCKER_METADATA $DOCKER_BUILD_ARGS $*"
# shellcheck disable=SC2086
/kaniko/executor --context "$(docker_context_path)" --dockerfile "$DOCKER_FILE" --destination "$docker_image" --cache --cache-dir="$KANIKO_CACHE_DIR" --verbosity $DOCKER_KANIKO_VERBOSITY $kaniko_registry_mirror_option $DOCKER_METADATA $DOCKER_BUILD_ARGS "$@"
/kaniko/executor --context "$(docker_context_path)" --dockerfile "$DOCKER_FILE" --destination "$docker_image" --cache --cache-dir="${CI_PROJECT_DIR}/.cache" --cache-repo="$kaniko_registry_repository" --verbosity $DOCKER_KANIKO_VERBOSITY $kaniko_registry_mirror_option $DOCKER_METADATA $DOCKER_BUILD_ARGS "$@"
}
# Used by containers tools like buildah, skopeo.
......@@ -456,7 +457,6 @@ stages:
name: "$DOCKER_KANIKO_IMAGE"
entrypoint: [""]
variables:
KANIKO_CACHE_DIR: "${CI_PROJECT_DIR}/.cache"
BUILDTOOL_HOME: "/kaniko"
cache:
key: "$CI_COMMIT_REF_SLUG-docker"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment