Commit e44cb279 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'dev/refactor' into 'master'

feat: introduce variable for additional docker/buildah push arguments

Closes #86

See merge request to-be-continuous/docker!120
parents ad7251ff 9de48b24
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -298,13 +298,14 @@ 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)     |
| `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)):

+5 −0
Original line number Diff line number Diff line
@@ -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": [
+6 −2
Original line number Diff line number Diff line
@@ -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