-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makefile: add multiarch building support #203
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,53 @@ KUBECONFIG := | |
yaml_templates := $(wildcard *.yaml.template) | ||
yaml_instances := $(patsubst %.yaml.template,%.yaml,$(yaml_templates)) | ||
|
||
ARCH ?= amd64 | ||
ALL_ARCH = amd64 arm64 | ||
|
||
IMAGEARCH ?= | ||
QEMUARCH ?= | ||
|
||
ifneq ($(ARCH),amd64) | ||
IMAGE_TAG = $(IMAGE_REPO)-$(ARCH):$(IMAGE_TAG_NAME) | ||
endif | ||
|
||
ifeq ($(ARCH),amd64) | ||
IMAGEARCH = | ||
QEMUARCH = x86_64 | ||
else ifeq ($(ARCH),arm) | ||
IMAGEARCH = arm32v7/ | ||
QEMUARCH = arm | ||
else ifeq ($(ARCH),arm64) | ||
IMAGEARCH = arm64v8/ | ||
QEMUARCH = aarch64 | ||
else ifeq ($(ARCH),ppc64le) | ||
IMAGEARCH = ppc64le/ | ||
QEMUARCH = ppc64le | ||
else ifeq ($(ARCH),s390x) | ||
IMAGEARCH = s390x/ | ||
QEMUARCH = s390x | ||
else | ||
$(error unknown arch "$(ARCH)") | ||
endif | ||
|
||
all: image | ||
|
||
image: yamls | ||
$(IMAGE_BUILD_CMD) --build-arg NFD_VERSION=$(VERSION) \ | ||
--build-arg IMAGEARCH=$(IMAGEARCH) \ | ||
--build-arg QEMUARCH=$(QEMUARCH) \ | ||
-t $(IMAGE_TAG) \ | ||
$(IMAGE_BUILD_EXTRA_OPTS) ./ | ||
|
||
pre-cross: | ||
docker run --rm --privileged multiarch/qemu-user-static:register --reset | ||
|
||
# Building multi-arch docker images | ||
images-all: pre-cross | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
for arch in $(ALL_ARCH); do \ | ||
$(MAKE) image ARCH=$$arch; \ | ||
done | ||
|
||
yamls: $(yaml_instances) | ||
|
||
%.yaml: %.yaml.template .FORCE | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -593,6 +593,19 @@ cd <project-root> | |
make | ||
``` | ||
|
||
**Build non-amd64 image on amd64:**<br> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: this just looks a bit clumsy heading 😄 How about |
||
Optional, for example. | ||
``` | ||
cd <project-root> | ||
docker run --rm --privileged multiarch/qemu-user-static:register --reset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would |
||
make image ARCH=arm64 | ||
``` | ||
Or, you can build all supported amd64/non-amd64 images together. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest |
||
``` | ||
cd <project-root> | ||
make images-all | ||
``` | ||
|
||
**Push the container image:**<br> | ||
Optional, this example with Docker. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QEMU version needs to be update