Skip to content

Commit 11b5e9a

Browse files
authored
Cross-compile koperator for arm and intel. (#84)
1 parent b37a977 commit 11b5e9a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ docker-build: ## Build the operator docker image.
156156
docker-push: ## Push the operator docker image.
157157
docker push ${IMG}
158158

159+
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
160+
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
161+
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
162+
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
163+
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
164+
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
165+
PLATFORMS ?= linux/arm64,linux/amd64
166+
.PHONY: docker-buildx
167+
docker-buildx: ## Build and push docker image for the manager for cross-platform support
168+
- docker buildx create --name koperator-builder
169+
docker buildx use koperator-builder
170+
docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile .
171+
- docker buildx rm koperator-builder
172+
159173
bin/controller-gen: bin/controller-gen-$(CONTROLLER_GEN_VERSION) ## Symlink controller-gen-<version> into versionless controller-gen.
160174
@ln -sf controller-gen-$(CONTROLLER_GEN_VERSION) bin/controller-gen
161175

0 commit comments

Comments
 (0)