Skip to content

Commit

Permalink
[dockerhub] push arm64 images too, with multiarch tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mostynb committed Jun 27, 2021
1 parent 6d7778d commit fc5a53a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
25 changes: 23 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ container_image(
name = "bazel-remote-image",
base = ":bazel-remote-base",
cmd = ["--max_size=5"],
architecture = "amd64",
entrypoint = [
"/app/bazel-remote-base.binary",
"--port=8080",
Expand All @@ -93,6 +94,7 @@ container_image(
container_image(
name = "bazel-remote-image-arm64",
base = ":bazel-remote-base-arm64",
architecture = "arm64",
cmd = ["--max_size=1"],
entrypoint = [
"/app/bazel-remote-base-arm64.binary",
Expand All @@ -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"],
)
19 changes: 19 additions & 0 deletions docker/push_to_dockerhub
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit fc5a53a

Please sign in to comment.