Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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
andypost marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: all build push

Expand All @@ -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) \
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Author

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

Copy link
Contributor

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

--no-cache --progress=plain \
--build-arg COMPOSER_HASH=$(COMPOSER_HASH) \
--build-arg DRUSH_VERSION=$(DRUSH_VERSION) \
Expand All @@ -28,3 +27,15 @@ push:

unit:
make -C unit-php-builder/dev build

buildx-push:
@echo "Building and pushing images for tags: $(TAGS)"
set -e; for i in $(TAGS); do printf "\nBuilding $(NAME):$$i \n\n"; cd php$$i; \
docker buildx build -t $(NAME):$$i --push \
--platform $(PLATFORM) \
--no-cache --progress=plain \
--build-arg COMPOSER_HASH=$(COMPOSER_HASH) \
--build-arg DRUSH_VERSION=$(DRUSH_VERSION) \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VCS_REF=`git rev-parse --short HEAD` .; \
cd ..; done