Skip to content

Commit bfa5ef1

Browse files
Fix Docker multi-arch build by using buildx directly (#1935)
* Initial plan * Fix Docker push by using buildx for multi-arch builds Replace separate docker build commands with docker buildx build that properly handles multi-platform builds. This fixes the "is a manifest list" error that occurred when trying to create manifests from images built with docker build --platform. The new approach uses docker buildx build with --platform linux/amd64,linux/arm64 to build both architectures in one command and pushes them directly with the --push flag. Co-authored-by: jordanstephens <706922+jordanstephens@users.noreply.github.com> * Remove unused Docker image variables Co-authored-by: jordanstephens <706922+jordanstephens@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jordanstephens <706922+jordanstephens@users.noreply.github.com>
1 parent a9cfe07 commit bfa5ef1

1 file changed

Lines changed: 8 additions & 41 deletions

File tree

src/Makefile

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -191,51 +191,18 @@ PROJECT_NAME := defang-cli
191191
DOCKER_REPO:=defangio
192192
DOCKER_IMAGE_NAME:=$(DOCKER_REPO)/$(PROJECT_NAME)
193193

194-
DOCKER_IMAGE_ARM64:=$(DOCKER_IMAGE_NAME):arm64-$(VERSION)
195-
DOCKER_IMAGE_AMD64:=$(DOCKER_IMAGE_NAME):amd64-$(VERSION)
196-
197-
.PHONY: image-amd64
198-
image-amd64:
199-
docker build \
200-
--platform linux/amd64 \
201-
-t ${PROJECT_NAME} \
202-
-t $(DOCKER_IMAGE_AMD64) \
203-
--build-arg VERSION=$(VERSION) \
204-
--build-arg GO_VERSION=$(GO_VERSION) \
205-
.
206-
207-
.PHONY: image-arm64
208-
image-arm64:
209-
docker build \
210-
--platform linux/arm64 \
211-
-t ${PROJECT_NAME} \
212-
-t $(DOCKER_IMAGE_ARM64) \
194+
## Build and push multi-arch Docker images
195+
.PHONY: push-images
196+
push-images: login
197+
docker buildx build \
198+
--platform linux/amd64,linux/arm64 \
199+
--push \
200+
-t $(DOCKER_IMAGE_NAME):$(VERSION) \
201+
-t $(DOCKER_IMAGE_NAME):latest \
213202
--build-arg VERSION=$(VERSION) \
214203
--build-arg GO_VERSION=$(GO_VERSION) \
215204
.
216205

217-
## Build all docker images and manifest
218-
.PHONY: images
219-
images: image-amd64 image-arm64
220-
221-
## Push all docker images
222-
.PHONY: push-images
223-
push-images: images login
224-
docker push $(DOCKER_IMAGE_AMD64)
225-
docker push $(DOCKER_IMAGE_ARM64)
226-
docker manifest create --amend \
227-
$(DOCKER_IMAGE_NAME):$(VERSION) \
228-
$(DOCKER_IMAGE_AMD64) \
229-
$(DOCKER_IMAGE_ARM64)
230-
docker manifest create --amend \
231-
$(DOCKER_IMAGE_NAME):latest \
232-
$(DOCKER_IMAGE_AMD64) \
233-
$(DOCKER_IMAGE_ARM64)
234-
docker manifest push --purge \
235-
$(DOCKER_IMAGE_NAME):$(VERSION)
236-
docker manifest push --purge \
237-
$(DOCKER_IMAGE_NAME):latest
238-
239206
## Login to docker
240207
.PHONY: login
241208
login:

0 commit comments

Comments
 (0)