From 569bb1cf6322af888b355ab24ecdbd9f64c5e927 Mon Sep 17 00:00:00 2001 From: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:56:19 +0530 Subject: [PATCH] Add support for multi-arch Docker images (#1362) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Changes This PR follows instructions in https://goreleaser.com/cookbooks/multi-platform-docker-images/ to create a multi-arch docker CLI image. Thus customers can simply specify `docker pull ghcr.io/databricks/cli:latest` to pull and run the image. The current approach uses the `docker manifest` support in goreleaser to create a multi-arch image. This has a couple of pros and cons. TLDR; The changes as is in the PR are good to go and very low risk. The information provided here is just FYI. pros: Fewer configurations/workflows for us to manage/maintain. Goreleaser makes sure the correct CLI binary is in place when building the CLI and also takes care of publishing it to the Github Container Registry. cons: Goreleaser only supports [docker manifest](https://docs.docker.com/reference/cli/docker/manifest/) to create multi-arch images. This has a few minor disadvantages: 1. `goreleaser` pushes all intermediate images (arm64 and and64 specific images) to the registry. This is required for the manifest to reference them. See: https://github.com/goreleaser/goreleaser/issues/2606 Note: We have a migration path here, if someday we stop publishing intermediate images, we can simply tag the "multi-arch" image as both `latest-amd64` and `latest-arm64`. For now, these are separate images. see: https://github.com/databricks/cli/pkgs/container/cli 2. `docker manifest` is technically an experimental command. Though it's been out for multiple years now and the indirect dependency by `goreleaser` should be fine. In any case, we can migrate by moving our docker build process off goreleaser if we need to. ## Tests Tested manually by publishing a new release for `v0.0.0-docker` in ghcr.io. 1. Package: https://github.com/databricks/cli/pkgs/container/cli 2. Release workflow: https://github.com/databricks/cli/actions/runs/8689359851 Tests the image itself by running it manually: ``` ➜ cli git:(feature/multi-arch-docker) docker pull ghcr.io/databricks/cli:latest latest: Pulling from databricks/cli bca4290a9639: Already exists 6d445556910d: Already exists Digest: sha256:82eabc500b541a89182aed4d3158c955e57c1e84d9616b76510aceb1d9024425 Status: Downloaded newer image for ghcr.io/databricks/cli:latest ghcr.io/databricks/cli:latest What's Next? View a summary of image vulnerabilities and recommendations → docker scout quickview ghcr.io/databricks/cli:latest ➜ cli git:(feature/multi-arch-docker) docker run ghcr.io/databricks/cli --version Databricks CLI v0.0.0-docker ``` --- .goreleaser.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e4406874..d37876ed 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -75,6 +75,16 @@ dockers: - "./docker/config.tfrc" - "./docker/setup.sh" +docker_manifests: + - name_template: ghcr.io/databricks/cli:{{replace .Version "+" "-"}} + image_templates: + - ghcr.io/databricks/cli:{{replace .Version "+" "-"}}-amd64 + - ghcr.io/databricks/cli:{{replace .Version "+" "-"}}-arm64 + - name_template: ghcr.io/databricks/cli:latest + image_templates: + - ghcr.io/databricks/cli:latest-amd64 + - ghcr.io/databricks/cli:latest-arm64 + checksum: name_template: 'databricks_cli_{{ .Version }}_SHA256SUMS'