diff --git a/README.md b/README.md index d8a87bac5508b8b4a2a2c110391a7ae8efda0d45..8c09f2682836e1d8d896df0410358125ca563cd7 100644 --- a/README.md +++ b/README.md @@ -345,7 +345,7 @@ It is bound to the `package-build` stage, and uses the following variables: | :lock: `DOCKER_REGISTRY_MIRROR_PASSWORD` | Docker registry password for the mirror registry | _(none)_ | | `container-registries-config-file` / `CONTAINER_REGISTRIES_CONFIG_FILE` | The [`registries.conf`](https://www.redhat.com/sysadmin/manage-container-registries) configuration to be used
:warning: Used by the `buildah` build only | _(none)_ | | `metadata` / `DOCKER_METADATA` | Additional `docker build`/`kaniko` arguments to set label | OCI Image Format Specification | -| `kaniko-snapshot-image-cache` / `KANIKO_SNAPSHOT_IMAGE_CACHE` | Snapshot image repository that will be used to store cached layers (leave empty to use default: snapshot image repository + `/cache`)
:warning: Used by the `kaniko` build only | _none_ (default cache path) | +| `build-cache-location` / `DOCKER_BUILD_CACHE_LOCATION` | Location to store cached layers when using build-cache (leave empty to use default: snapshot-image + `/cache`)
:warning: Used by the `kaniko` and `buildah` build only | snapshot-image + `/cache` | | `build-cache-disabled` / `DOCKER_BUILD_CACHE_DISABLED` | Set to `true` to disable the build cache.
Cache can typically be disabled when there is a network latency between the container registry and the runner. | _none_ (i.e cache enabled) | | `push-args` / `DOCKER_PUSH_ARGS` | Additional `push` arguments for [docker](https://docs.docker.com/reference/cli/docker/image/push/) or [buildah](https://github.com/containers/buildah/blob/main/docs/buildah-push.1.md) (executed right after `build`).
Ex: `--compression-format zstd --compression-level 20` | _(none)_ | diff --git a/kicker.json b/kicker.json index cb7565aa99a37fb417d49bfd23731d2a647b1311..0fac255dd4a2f7e1cee83697433581a048f94ba4 100644 --- a/kicker.json +++ b/kicker.json @@ -110,17 +110,17 @@ "description": "The [registries.conf](https://www.redhat.com/sysadmin/manage-container-registries) configuration to be used\n\n_Used by the `buildah` build only_", "advanced": true }, - { - "name": "KANIKO_SNAPSHOT_IMAGE_CACHE", - "description": "Snapshot image repository that will be used to store cached layers (leave empty to use default: snapshot image repository + `/cache`)\n\n_Used by the `kaniko` build only_", - "advanced": true - }, { "name": "DOCKER_BUILD_CACHE_DISABLED", "description": "Set to `true` to disable the build cache.", "type": "boolean", "advanced": true }, + { + "name": "DOCKER_BUILD_CACHE_LOCATION", + "description": "Location to store cached layers when using build-cache (leave empty to use default: snapshot-image + `/cache`)\n\n_Used by the `kaniko` and `buildah` build only_", + "advanced": true + }, { "name": "DOCKER_PUSH_ARGS", "description": "Additional docker/buildah `push` arguments (executed right after `build`).\n\nEx: `--compression-format zstd --compression-level 20`", diff --git a/templates/gitlab-ci-docker.yml b/templates/gitlab-ci-docker.yml index 94311a08df8db3b311c70f69e3b4b79a76e99250..aaf54458d464c3964251763baec488936573ab6c 100644 --- a/templates/gitlab-ci-docker.yml +++ b/templates/gitlab-ci-docker.yml @@ -87,6 +87,12 @@ spec: description: Disable the build cache type: boolean default: false + build-cache-location: + description: |- + Location to store cached layers when using build-cache (leave empty to use default: snapshot-image + `/cache`) + + _Used by the `kaniko` and `buildah` build only_ + default: '' metadata: description: Additional metadata to set as labels default: >- @@ -122,12 +128,6 @@ spec: _Used by the `buildah` build only_ default: '' - kaniko-snapshot-image-cache: - description: |- - Snapshot image repository that will be used to store cached layers (leave empty to use default: snapshot image repository + `/cache`) - - _Used by the `kaniko` build only_ - default: '' hadolint-disabled: description: Disable Hadolint type: boolean @@ -315,11 +315,11 @@ variables: DOCKER_RELEASE_EXTRA_TAGS: $[[ inputs.release-extra-tags ]] DOCKER_BUILD_ARGS: $[[ inputs.build-args ]] DOCKER_BUILD_CACHE_DISABLED: $[[ inputs.build-cache-disabled ]] + DOCKER_BUILD_CACHE_LOCATION: $[[ inputs.build-cache-location ]] DOCKER_PUBLISH_ARGS: $[[ inputs.publish-args ]] DOCKER_SEMREL_RELEASE_DISABLED: $[[ inputs.semrel-release-disabled ]] DOCKER_REGISTRY_MIRROR: $[[ inputs.registry-mirror ]] CONTAINER_REGISTRIES_CONFIG_FILE: $[[ inputs.container-registries-config-file ]] - KANIKO_SNAPSHOT_IMAGE_CACHE: $[[ inputs.kaniko-snapshot-image-cache ]] DOCKER_PUSH_ARGS: $[[ inputs.push-args ]] DOCKER_HADOLINT_DISABLED: $[[ inputs.hadolint-disabled ]] DOCKER_HADOLINT_ARGS: $[[ inputs.hadolint-args ]] @@ -827,7 +827,8 @@ stages: function run_build_kaniko() { docker_image=$1 if [ "$DOCKER_BUILD_CACHE_DISABLED" != "true" ]; then - kaniko_snapshot_image_cache="${KANIKO_SNAPSHOT_IMAGE_CACHE:-${DOCKER_SNAPSHOT_IMAGE%:*}/cache}" + # Backward compatibility until buildah become the default build tool + kaniko_snapshot_image_cache="${KANIKO_SNAPSHOT_IMAGE_CACHE:-${DOCKER_BUILD_CACHE_LOCATION:-${DOCKER_SNAPSHOT_IMAGE%:*}/cache}}" kaniko_cache_args="--cache --cache-dir=${CI_PROJECT_DIR}/.cache --cache-repo=${kaniko_snapshot_image_cache}" log_info "Build cache enabled; CLI options: ${kaniko_cache_args}" fi @@ -1130,7 +1131,7 @@ docker-buildah-build: # Add build cache related parameters. - | if [ "$DOCKER_BUILD_CACHE_DISABLED" != "true" ]; then - buildah_build_cache="${DOCKER_SNAPSHOT_IMAGE%:*}/cache" + buildah_build_cache="${DOCKER_BUILD_CACHE_LOCATION:-${DOCKER_SNAPSHOT_IMAGE%:*}/cache}" buildah_cache_args="--layers --cache-from $buildah_build_cache --cache-to $buildah_build_cache" log_info "Build cache enabled; CLI options: ${buildah_cache_args}" fi