From 55d275535c763db354dc9aa745f3f08131898273 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 25 Mar 2024 21:42:18 -0400 Subject: [PATCH 1/6] Makefile: support OCI_EXE environmental variable Allow setting podman for image builds. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3bf56a3..0099084 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # # Name of the docker executable -DOCKER := docker +DOCKER := $(or $(OCI_EXE), docker) # Docker organization to pull the images from ORG = dockcross From ba27b1fc51431a30da338979ad66823659dbb94e Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 25 Mar 2024 22:11:11 -0400 Subject: [PATCH 2/6] WIP: Support multi-platform amd64, arm64 host images --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0099084..c38f710 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,8 @@ $(GEN_IMAGE_DOCKERFILES) Dockerfile: %Dockerfile: %Dockerfile.in $(DOCKER_COMPOS web-wasm: web-wasm/Dockerfile mkdir -p $@/imagefiles && cp -r imagefiles $@/ cp -r test web-wasm/ - $(DOCKER) build -t $(ORG)/web-wasm:$(TAG) \ + $(DOCKER) buildx build -t $(ORG)/web-wasm:$(TAG) \ + --platform linux/amd64,linux/arm64 \ -t $(ORG)/web-wasm:latest \ --build-arg IMAGE=$(ORG)/web-wasm \ --build-arg VERSION=$(TAG) \ From 50120593a37cd25ef98698a25aaa2c8b0379812c Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 25 Mar 2024 22:28:04 -0400 Subject: [PATCH 3/6] Makefile: define BUILD_CMD and apply to web-wasm Note, when setting, QEMU needs to be installed in the Linux kernel with something like: $ docker run --privileged --rm tonistiigi/binfmt --install all Per: https://github.com/docker/buildx --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c38f710..00aa895 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,13 @@ # Name of the docker executable DOCKER := $(or $(OCI_EXE), docker) +# The build sub-command. Use: +# +# export "BUILD_CMD=buildx build --platform linux/amd64,linux/arm64" +# +# to generate multi-platform images. +BUILD_CMD := $(or $(BUILD_CMD), build) + # Docker organization to pull the images from ORG = dockcross @@ -118,8 +125,7 @@ $(GEN_IMAGE_DOCKERFILES) Dockerfile: %Dockerfile: %Dockerfile.in $(DOCKER_COMPOS web-wasm: web-wasm/Dockerfile mkdir -p $@/imagefiles && cp -r imagefiles $@/ cp -r test web-wasm/ - $(DOCKER) buildx build -t $(ORG)/web-wasm:$(TAG) \ - --platform linux/amd64,linux/arm64 \ + $(DOCKER) $(BUILD_CMD) -t $(ORG)/web-wasm:$(TAG) \ -t $(ORG)/web-wasm:latest \ --build-arg IMAGE=$(ORG)/web-wasm \ --build-arg VERSION=$(TAG) \ From 9f4fe909238fa8cce5ac94ec6ec05bbad6504088 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 25 Mar 2024 22:31:12 -0400 Subject: [PATCH 4/6] Makefile: apply BUILD_CMD to the base image --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 00aa895..355e086 100644 --- a/Makefile +++ b/Makefile @@ -232,7 +232,7 @@ manylinux2014-x86.test: manylinux2014-x86 # base # base: Dockerfile imagefiles/ - $(DOCKER) build -t $(ORG)/base:latest \ + $(DOCKER) $(BUILD_CMD) -t $(ORG)/base:latest \ -t $(ORG)/base:$(TAG) \ --build-arg IMAGE=$(ORG)/base \ --build-arg VCS_URL=`git config --get remote.origin.url` \ From 0ee05c1f5a5114de52681d9dce84e723e7d631db Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 25 Mar 2024 22:33:07 -0400 Subject: [PATCH 5/6] Makefile: apply BUILD_CMD to standard images --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 355e086..6c1a2d4 100644 --- a/Makefile +++ b/Makefile @@ -254,7 +254,7 @@ $(VERBOSE).SILENT: display_images $(STANDARD_IMAGES): %: %/Dockerfile base mkdir -p $@/imagefiles && cp -r imagefiles $@/ - $(DOCKER) build -t $(ORG)/$@:latest \ + $(DOCKER) $(BUILD_CMD) -t $(ORG)/$@:latest \ -t $(ORG)/$@:$(TAG) \ --build-arg ORG=$(ORG) \ --build-arg IMAGE=$(ORG)/$@ \ From 00e75583b2018007aafb1de8761e3887a737e804 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 25 Mar 2024 22:53:11 -0400 Subject: [PATCH 6/6] ci: build the base image for both arm64 and amd64 --- .github/workflows/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c5b98d7..a24bcf1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,15 @@ jobs: submodules: "recursive" fetch-depth: 1 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: build + env: + BUILD_CMD: buildx build --platform linux/amd64,linux/arm64 run: make base - name: test