Working Makefile

This commit is contained in:
Jean-Marc ANDRE 2023-04-17 23:01:35 +02:00
parent 005d02e891
commit 9fb54034c2

View File

@ -1,8 +1,10 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
VERSION ?= latest
IMG ?= docker.io/desmo999r/formolcontroller:$(VERSION)
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.25.0
MANIFEST = formolcontroller-multiarch
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
@ -68,6 +70,7 @@ build: manifests generate fmt vet ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
PLATFORMS ?= linux/arm64,linux/amd64
# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
@ -75,9 +78,14 @@ run: manifests generate fmt vet ## Run a controller from your host.
docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .
.PHONY: docker-build-multiarch
docker-build-multiarch:
buildah bud --manifest $(MANIFEST) --platform=$(PLATFORMS) Dockerfile.multi
.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${IMG}
buildah manifest psuh --all --rm $(MANIFEST) "docker://$(IMG)"
#docker push ${IMG}
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
@ -85,7 +93,6 @@ docker-push: ## Push docker image with the manager.
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To properly provided solutions that supports more than one platform you should use this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile