diff --git a/README.md b/README.md index dfb9f97860262f4a54b33c51db239b6b2317f733..39d90d1f6be76974aa265419ca11c36fa6a63d73 100644 --- a/README.md +++ b/README.md @@ -297,14 +297,15 @@ This job builds the image and publishes it to the _snapshot_ repository. It is bound to the `package-build` stage, and uses the following variables: -| Input / Variable | Description | Default value | -| ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | -| `build-args` / `DOCKER_BUILD_ARGS` | Additional `docker/kaniko/buildah` `build` arguments | _(none)_ | -| `registry-mirror` / `DOCKER_REGISTRY_MIRROR` | URL of a Docker registry mirror to use during the image build (instead of default `https://index.docker.io`) <br>:warning: Used by the `kaniko` and `dind` options only | _(none)_ | -| `container-registries-config-file` / `CONTAINER_REGISTRIES_CONFIG_FILE` | The [`registries.conf`](https://www.redhat.com/sysadmin/manage-container-registries) configuration to be used<br>: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`)<br>:warning: Used by the `kaniko` build only | _none_ (default cache path) | -| `build-cache-disabled` / `DOCKER_BUILD_CACHE_DISABLED` | Set to `true` to disable the build cache.<br/>Cache can typically be disabled when there is a network latency between the container registry and the runner. | _none_ (i.e cache enabled) | +| Input / Variable | Description | Default value | +|-------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------| +| `build-args` / `DOCKER_BUILD_ARGS` | Additional `docker/kaniko/buildah` `build` arguments | _(none)_ | +| `registry-mirror` / `DOCKER_REGISTRY_MIRROR` | URL of a Docker registry mirror to use during the image build (instead of default `https://index.docker.io`) <br>:warning: Used by the `kaniko` and `dind` options only | _(none)_ | +| `container-registries-config-file` / `CONTAINER_REGISTRIES_CONFIG_FILE` | The [`registries.conf`](https://www.redhat.com/sysadmin/manage-container-registries) configuration to be used<br>: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`)<br>:warning: Used by the `kaniko` build only | _none_ (default cache path) | +| `build-cache-disabled` / `DOCKER_BUILD_CACHE_DISABLED` | Set to `true` to disable the build cache.<br/>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`).<br>Ex: `--compression-format zstd --compression-level 20` | _(none)_ | This job produces _output variables_ that are propagated to downstream jobs (using [dotenv artifacts](https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html#artifactsreportsdotenv)): diff --git a/kicker.json b/kicker.json index 2a793e4a6af1504cccea0400a23675ae5de63653..5fa92ebfcf5182d1f637e2dd0397fa3b9b3a7196 100644 --- a/kicker.json +++ b/kicker.json @@ -120,6 +120,11 @@ "description": "Set to `true` to disable the build cache.", "type": "boolean", "advanced": true + }, + { + "name": "DOCKER_PUSH_ARGS", + "description": "Additional docker/buildah `push` arguments (executed right after `build`).\n\nEx: `--compression-format zstd --compression-level 20`", + "advanced": true } ], "features": [ diff --git a/templates/gitlab-ci-docker.yml b/templates/gitlab-ci-docker.yml index c5b62625bbbf559f1ccaf011d5cdd10dd0149606..ed38c8916b198badc274c183691b1e8ca612029c 100644 --- a/templates/gitlab-ci-docker.yml +++ b/templates/gitlab-ci-docker.yml @@ -79,6 +79,9 @@ spec: build-args: description: Additional docker/kaniko/buildah build arguments default: '' + push-args: + description: Additional docker/buildah `push` arguments (executed right after `build`) + default: '' build-cache-disabled: description: Disable the build cache type: boolean @@ -285,6 +288,7 @@ variables: 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 ]] DOCKER_HEALTHCHECK_DISABLED: $[[ inputs.healthcheck-disabled ]] @@ -800,7 +804,7 @@ docker-dind-build: fi # Build using cache if exist - echo $DOCKER_METADATA $DOCKER_BUILD_ARGS "$(docker_context_path)" | xargs docker build --file "$DOCKER_FILE" ${dind_cache_args} --tag $DOCKER_SNAPSHOT_IMAGE --build-arg http_proxy="$http_proxy" --build-arg https_proxy="$https_proxy" --build-arg no_proxy="$no_proxy" - - docker push $DOCKER_SNAPSHOT_IMAGE + - docker push $DOCKER_PUSH_ARGS $DOCKER_SNAPSHOT_IMAGE # Display the size of each layer - docker history $DOCKER_SNAPSHOT_IMAGE # Display the total size of the image @@ -843,7 +847,7 @@ docker-buildah-build: buildah version # build and push image - echo $DOCKER_METADATA $DOCKER_BUILD_ARGS "$(docker_context_path)" | xargs buildah build --file "$DOCKER_FILE" --tag $DOCKER_SNAPSHOT_IMAGE $buildah_cache_args --build-arg http_proxy="$http_proxy" --build-arg https_proxy="$https_proxy" --build-arg no_proxy="$no_proxy" - - buildah push --digestfile .img-digest.txt "$DOCKER_SNAPSHOT_IMAGE" + - buildah push --digestfile .img-digest.txt $DOCKER_PUSH_ARGS "$DOCKER_SNAPSHOT_IMAGE" # display digest of the resulting image - cat .img-digest.txt # create dotenv file