-
Notifications
You must be signed in to change notification settings - Fork 16
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
Use buildx to support multi-arch images #86
base: master
Are you sure you want to change the base?
Conversation
@@ -14,7 +14,6 @@ build: | |||
@echo "Building images for tags: $(TAGS)" | |||
set -e; for i in $(TAGS); do printf "\nBuilding $(NAME):$$i \n\n"; cd php$$i; \ | |||
DOCKER_BUILDKIT=$(DOCKER_BUILDKIT) docker build -t $(NAME):$$i \ | |||
--platform $(PLATFORM) \ |
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.
this option is available because DOCKER_BUILDKIT=1
means that build is using buildx
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.
Otherwise it needs just to replace s/build/buildx
and remove there DOCKER_BUILDKIT
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.
From my experience, simple build
is like buildx build --load
which doesn't provide multiarch.
BTW, since Docker 23 it's always buildkit, but it still doesn't support multiarch for build
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.
I mean we just need to remove usage of DOCKER_BUILDKIT
Used following patch to try build diff --git a/Makefile b/Makefile
index 306cf99..dd658d0 100644
--- a/Makefile
+++ b/Makefile
@@ -3,18 +3,18 @@ TAGS ?= 81 81-fpm 81-unit 82 82-fpm 82-unit
COMPOSER_HASH ?= 55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae
DRUSH_VERSION ?= 8.4.12
-DOCKER_BUILDKIT ?= 1
-PLATFORM ?= linux/amd64
+PLATFORM ?= linux/amd64,linux/arm64
-.PHONY: all build push
+.PHONY: all build push prepare
all: build push
build:
@echo "Building images for tags: $(TAGS)"
set -e; for i in $(TAGS); do printf "\nBuilding $(NAME):$$i \n\n"; cd php$$i; \
- DOCKER_BUILDKIT=$(DOCKER_BUILDKIT) docker build -t $(NAME):$$i \
+ docker buildx build -t $(NAME):$$i \
--platform $(PLATFORM) \
+ --push \
--no-cache --progress=plain \
--build-arg COMPOSER_HASH=$(COMPOSER_HASH) \
--build-arg DRUSH_VERSION=$(DRUSH_VERSION) \
@@ -28,3 +28,7 @@ push:
unit:
make -C unit-php-builder/dev build
+
+prepare:
+ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
+ docker buildx create --use It means the builder needs setup (qemu) Moreover the problem is that you can only push image (it's not stored locally) |
@ lexbritvin I pushed this way the |
I think we need 2 makefile targets :
|
I don't know/see how you tag specific versions except upstream tags. Please, correct me if I'm wrong or describe the build flow more precisely. |
Yes, you're right, so one target to push tagged release and another for latest ones |
btw as I got |
For the
FYI You can actually attach different contexts to a builder to support native builds on remote machines (rpi4 or vps) without QEMU, if you are an enthusiast 😉 For me, a preparing step is strange to have in Makefile because it must be done once in the environment, like installing Docker. |
Hello @andypost ! |
Oh, I see you already push to 81 and 82. |
I can rebuild |
@lexbritvin please try pull fresh |
To provide multi-arch images, we have to use
buildx
in the builds.Due to standard
build
command doesn't support multi-arch builds, andbuildx --load
doesn't allow making multi-arch images locally also,make build
must only be used for building images locally for the current arch.New target
make buildx-push
is introduced to create multi-arch images and is intended to build and push images to Docker Hub as a default way.We have to agree on the best build flow here and maybe introduce github actions to simplify the build procedure.
We must also rebuild the images for php74 to support older projects.