diff --git a/BUILD.bazel b/BUILD.bazel index ad3a96f3a..f7250746d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -69,6 +69,7 @@ go_image( container_image( name = "bazel-remote-image", + architecture = "amd64", base = ":bazel-remote-base", cmd = ["--max_size=5"], entrypoint = [ @@ -92,6 +93,7 @@ container_image( container_image( name = "bazel-remote-image-arm64", + architecture = "arm64", base = ":bazel-remote-base-arm64", cmd = ["--max_size=1"], entrypoint = [ @@ -113,12 +115,31 @@ container_image( visibility = ["//visibility:public"], ) +# The following container_push targets push to "tmp-amd64" and "tmp-arm64" +# tags, so they can be combined into a multiarch tag on dockerhub. This +# isn't currently possible with rules_docker, so instead we rely on some +# external commands to be run after the tmp-* tags are pushed. See the +# docker/push_to_dockerhub script. +# +# Background: +# https://github.com/bazelbuild/rules_docker/issues/1599 + container_push( - name = "push_to_dockerhub", + name = "push_to_dockerhub_amd64", format = "Docker", image = ":bazel-remote-image", registry = "index.docker.io", repository = "buchgr/bazel-remote-cache", - tag = "latest", + tag = "tmp-amd64", + visibility = ["//visibility:public"], +) + +container_push( + name = "push_to_dockerhub_arm64", + format = "Docker", + image = ":bazel-remote-image-arm64", + registry = "index.docker.io", + repository = "buchgr/bazel-remote-cache", + tag = "tmp-arm64", visibility = ["//visibility:public"], ) diff --git a/docker/push_to_dockerhub b/docker/push_to_dockerhub new file mode 100755 index 000000000..c7536b87a --- /dev/null +++ b/docker/push_to_dockerhub @@ -0,0 +1,19 @@ +#!/bin/bash + +script_dir=$(dirname "${BASH_SOURCE[0]}") +cd "${script_dir}/.." + +# push test-amd64 and test-arm64 images. +bazel run //:push_to_dockerhub_amd64 +bazel run //:push_to_dockerhub_arm64 + +# Create the multiarch manifest. +docker manifest rm buchgr/bazel-remote-cache:latest +docker manifest create buchgr/bazel-remote-cache:latest \ + --amend buchgr/bazel-remote-cache:tmp-amd64 \ + --amend buchgr/bazel-remote-cache:tmp-arm64 + +# Push the multiarch manifest +docker manifest push buchgr/bazel-remote-cache:latest + +echo "Go ahead and delete the tmp-amd64 and tmp-arm64 images from the web ui"