Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Push multi-arch compatible with DockerHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciprian Hacman committed Oct 27, 2020
1 parent 9b2d9f2 commit 87746c4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 14 deletions.
44 changes: 42 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

STABLE_DOCKER_REGISTRY := $(shell tools/get_workspace_status.sh | grep STABLE_DOCKER_REGISTRY | cut -d ' ' -f 2)
STABLE_DOCKER_IMAGE_PREFIX := $(shell tools/get_workspace_status.sh | grep STABLE_DOCKER_IMAGE_PREFIX | cut -d ' ' -f 2)
STABLE_DOCKER_TAG := $(shell tools/get_workspace_status.sh | grep STABLE_DOCKER_TAG | cut -d ' ' -f 2)
IMAGE_BASE := $(STABLE_DOCKER_REGISTRY)/$(STABLE_DOCKER_IMAGE_PREFIX)

BAZEL_FLAGS=--features=pure --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64

.PHONY: all
all: test

Expand All @@ -37,20 +43,54 @@ push-etcd-manager:
bazel run ${BAZEL_FLAGS} --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //images:push-etcd-manager
bazel run ${BAZEL_FLAGS} --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //images:push-etcd-manager

.PHONY: push-etcd-manager-manifest
push-etcd-manager-manifest:
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create \
$(IMAGE_BASE)etcd-manager:$(STABLE_DOCKER_TAG) \
$(IMAGE_BASE)etcd-manager:$(STABLE_DOCKER_TAG)-amd64 \
$(IMAGE_BASE)etcd-manager:$(STABLE_DOCKER_TAG)-arm64
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge \
$(IMAGE_BASE)etcd-manager:$(STABLE_DOCKER_TAG)

.PHONY: push-etcd-dump
push-etcd-dump:
bazel run ${BAZEL_FLAGS} --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //images:push-etcd-dump
bazel run ${BAZEL_FLAGS} --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //images:push-etcd-dump

.PHONY: push-etcd-dump-manifest
push-etcd-dump-manifest:
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create \
$(IMAGE_BASE)etcd-dump:$(STABLE_DOCKER_TAG) \
$(IMAGE_BASE)etcd-dump:$(STABLE_DOCKER_TAG)-amd64 \
$(IMAGE_BASE)etcd-dump:$(STABLE_DOCKER_TAG)-arm64
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge \
$(IMAGE_BASE)etcd-dump:$(STABLE_DOCKER_TAG)

.PHONY: push-etcd-backup
push-etcd-backup:
bazel run ${BAZEL_FLAGS} --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //images:push-etcd-backup
bazel run ${BAZEL_FLAGS} --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //images:push-etcd-backup

.PHONY: push
push: push-etcd-manager push-etcd-dump push-etcd-backup
.PHONY: push-etcd-backup-manifest
push-etcd-backup-manifest:
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create \
$(IMAGE_BASE)etcd-backup:$(STABLE_DOCKER_TAG) \
$(IMAGE_BASE)etcd-backup:$(STABLE_DOCKER_TAG)-amd64 \
$(IMAGE_BASE)etcd-backup:$(STABLE_DOCKER_TAG)-arm64
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge \
$(IMAGE_BASE)etcd-backup:$(STABLE_DOCKER_TAG)

.PHONY: push-images
push-images: push-etcd-manager push-etcd-dump push-etcd-backup
echo "pushed images"

.PHONY: push-manifests
push-manifests: push-etcd-manager-manifest push-etcd-dump-manifest push-etcd-backup-manifest
echo "pushed manifests"

.PHONY: push
push: push-images push-manifests

.PHONY: gazelle
gazelle:
bazel run //:gazelle -- fix
Expand Down
24 changes: 12 additions & 12 deletions images/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ container_push(
format = "Docker",
image = ":etcd-manager",
registry = "{STABLE_DOCKER_REGISTRY}",
repository = select({
"@io_bazel_rules_go//go/platform:amd64": "{STABLE_DOCKER_IMAGE_PREFIX}etcd-manager-amd64",
"@io_bazel_rules_go//go/platform:arm64": "{STABLE_DOCKER_IMAGE_PREFIX}etcd-manager-arm64",
repository = "{STABLE_DOCKER_IMAGE_PREFIX}etcd-manager",
tag = select({
"@io_bazel_rules_go//go/platform:amd64": "{STABLE_DOCKER_TAG}-amd64",
"@io_bazel_rules_go//go/platform:arm64": "{STABLE_DOCKER_TAG}-arm64",
}),
tag = "{STABLE_DOCKER_TAG}",
)

container_image(
Expand All @@ -132,11 +132,11 @@ container_push(
format = "Docker",
image = ":etcd-dump",
registry = "{STABLE_DOCKER_REGISTRY}",
repository = select({
"@io_bazel_rules_go//go/platform:amd64": "{STABLE_DOCKER_IMAGE_PREFIX}etcd-dump-amd64",
"@io_bazel_rules_go//go/platform:arm64": "{STABLE_DOCKER_IMAGE_PREFIX}etcd-dump-arm64",
repository = "{STABLE_DOCKER_IMAGE_PREFIX}etcd-dump",
tag = select({
"@io_bazel_rules_go//go/platform:amd64": "{STABLE_DOCKER_TAG}-amd64",
"@io_bazel_rules_go//go/platform:arm64": "{STABLE_DOCKER_TAG}-arm64",
}),
tag = "{STABLE_DOCKER_TAG}",
)

container_image(
Expand All @@ -158,9 +158,9 @@ container_push(
format = "Docker",
image = ":etcd-backup",
registry = "{STABLE_DOCKER_REGISTRY}",
repository = select({
"@io_bazel_rules_go//go/platform:amd64": "{STABLE_DOCKER_IMAGE_PREFIX}etcd-backup-amd64",
"@io_bazel_rules_go//go/platform:arm64": "{STABLE_DOCKER_IMAGE_PREFIX}etcd-backup-arm64",
repository = "{STABLE_DOCKER_IMAGE_PREFIX}etcd-backup",
tag = select({
"@io_bazel_rules_go//go/platform:amd64": "{STABLE_DOCKER_TAG}-amd64",
"@io_bazel_rules_go//go/platform:arm64": "{STABLE_DOCKER_TAG}-arm64",
}),
tag = "{STABLE_DOCKER_TAG}",
)

0 comments on commit 87746c4

Please sign in to comment.