Skip to content

Commit ff16db8

Browse files
committed
Add multi-arch image builds to makefile
A default set of platforms is specified and will build those if var `PLATFORMS` is not specified on the CLI Issue ansible#31 fixes ansible#1680
1 parent 07427be commit ff16db8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ docker-build: ## Build docker image with the manager.
107107
docker-push: ## Push docker image with the manager.
108108
${CONTAINER_CMD} push ${IMG}
109109

110+
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
111+
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
112+
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
113+
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
114+
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
115+
# To properly provided solutions that supports more than one platform you should use this option.
116+
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
117+
.PHONY: docker-buildx
118+
docker-buildx: ## Build and push docker image for the manager for cross-platform support
119+
- docker buildx create --name project-v3-builder
120+
docker buildx use project-v3-builder
121+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile .
122+
- docker buildx rm project-v3-builder
123+
124+
110125
##@ Deployment
111126

112127
.PHONY: install

0 commit comments

Comments
 (0)