Skip to content

Commit 0f9dc2a

Browse files
committed
Fix multiarch build when the host is aarch64
1 parent 547ddf3 commit 0f9dc2a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ LOCAL_PLATFORM := linux/$(shell uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64
55
VERSION ?= $(error VERSION is undefined. Usage: VERSION=x.y.z make [target])
66
VER_MAJOR := $(shell echo '$(VERSION)' | cut -d. -f1)
77
VER_MINOR := $(shell echo '$(VERSION)' | cut -d. -f2)
8+
BINFMT_IMAGE ?= tonistiigi/binfmt
9+
BINFMT_CMD ?= docker run --rm --privileged $(BINFMT_IMAGE) --install all
810

911
TAGS := -t $(REPO):v$(VER_MAJOR) \
1012
-t $(REPO):v$(VER_MAJOR).$(VER_MINOR) \
@@ -56,8 +58,12 @@ clean:
5658
docker buildx --builder multiarch prune -f
5759

5860
prepare:
59-
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
60-
docker buildx create --name multiarch --driver docker-container --use || true
61+
$(BINFMT_CMD)
62+
@if ! docker buildx inspect multiarch >/dev/null 2>&1; then \
63+
docker buildx create --name multiarch --driver docker-container --use --platform $(PLATFORMS); \
64+
else \
65+
docker buildx use multiarch; \
66+
fi
6167
docker buildx inspect --builder multiarch --bootstrap
6268

6369
check-version:

0 commit comments

Comments
 (0)