@@ -227,7 +227,7 @@ build-docker-binary: manifests generate fmt vet ## Build manager binary for Dock
227227 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/manager-linux.amd64 cmd/main.go
228228
229229.PHONY : docker-build
230- docker-build : build-docker-binary test # # Build docker image with the manager.
230+ docker-build : test build-docker-binary # # Build docker image with the manager.
231231 $(CONTAINER_TOOL ) build -t ${IMG} .
232232
233233.PHONY : docker-push
@@ -237,22 +237,14 @@ docker-push: ## Push docker image with the manager.
237237# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
238238# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
239239# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
240+ # - be using containerd image store with docker. More Info: https://docs.docker.com/engine/storage/containerd/
240241# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
241- # - 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)
242- # To properly provided solutions that supports more than one platform you should use this option.
243- PLATFORMS ?= linux/arm64 linux/amd64
242+
243+ PLATFORMS ?= linux/arm64,linux/amd64
244+
244245.PHONY : docker-buildx
245- docker-buildx : # # Build and tag docker image for each platform locally using --load
246- sed ' 1 s/^FROM/FROM --platform=$${BUILDPLATFORM}/' Dockerfile > Dockerfile.cross
247- $(CONTAINER_TOOL ) buildx create --name project-v3-builder || true
248- $(CONTAINER_TOOL ) buildx use project-v3-builder
249- @for platform in $(PLATFORMS ) ; do \
250- tag=" $( IMG) -$$ (echo $$ platform | tr / -)" ; \
251- echo " Building $$ tag for $$ platform" ; \
252- $(CONTAINER_TOOL ) buildx build --platform=$$ platform --tag $$ tag --load -f Dockerfile.cross . ; \
253- done
254- $(CONTAINER_TOOL ) buildx rm project-v3-builder
255- rm Dockerfile.cross
246+ docker-buildx : test
247+ $(CONTAINER_TOOL ) buildx build --platform=$(PLATFORMS ) --tag $(IMG ) --load -f Dockerfile .
256248
257249# ----------------------------------------------------------------------------------------------
258250# #@ Helm
@@ -375,14 +367,36 @@ dev-apply-metric-dynatrace-prod: ## Apply metric using Dynatrace production exam
375367
376368# ----------------------------------------------------------------------------------------------
377369# #@ Helm
370+
371+ HELM_VERSION ?= v3.18.0
372+ OCI_REGISTRY ?= ghcr.io/sap/charts
373+
374+ $(HELM ) : $(LOCALBIN )
375+ @if test -x $(LOCALBIN ) /helm && ! $(LOCALBIN ) /helm version --short | grep -q $(HELM_VERSION ) ; then \
376+ echo " $( LOCALBIN) /helm version is not expected $( HELM_VERSION) . Removing it before installing." ; \
377+ rm -rf $(LOCALBIN ) /helm; \
378+ fi
379+ test -s $(LOCALBIN ) /helm || (curl -sSL https://get.helm.sh/helm-$( HELM_VERSION) -$( shell uname | tr ' [:upper:]' ' [:lower:]' ) -amd64.tar.gz | tar xz -C /tmp && \
380+ mv /tmp/$(shell uname | tr '[:upper:]' '[:lower:]') -amd64/helm $(LOCALBIN ) /helm && \
381+ chmod +x $(LOCALBIN ) /helm && \
382+ rm -rf /tmp/$(shell uname | tr '[:upper:]' '[:lower:]') -amd64)
383+
384+ .PHONY : helm-package
385+ helm-package : $(HELM ) helm-chart
386+ $(LOCALBIN ) /helm package charts/$(PROJECT_FULL_NAME ) / -d ./ --version $(shell cat VERSION)
387+
388+ .PHONY : helm-push
389+ helm-push : $(HELM )
390+ $(LOCALBIN ) /helm push $(PROJECT_FULL_NAME ) -$(shell cat VERSION) .tgz oci://$(OCI_REGISTRY )
391+
378392.PHONY : helm-chart
379393helm-chart : # # Generate Helm chart files from templates.
380394 OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME ) /Chart.yaml.tpl > charts/$(PROJECT_FULL_NAME ) /Chart.yaml
381395 OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME ) /values.yaml.tpl > charts/$(PROJECT_FULL_NAME ) /values.yaml
382396
383397.PHONY : helm-install-local
384- helm-install-local : # # Install the Helm chart locally using the Docker image
385- helm upgrade --install $(PROJECT_FULL_NAME ) charts/$(PROJECT_FULL_NAME ) / --set image.repository=$(IMG_BASE ) --set image.tag=$(IMG_VERSION ) --set image.pullPolicy=Never
398+ helm-install-local : $( HELM ) # # Install the Helm chart locally using the Docker image
399+ $( LOCALBIN ) / helm upgrade --install $(PROJECT_FULL_NAME ) charts/$(PROJECT_FULL_NAME ) / --set image.repository=$(IMG_BASE ) --set image.tag=$(IMG_VERSION ) --set image.pullPolicy=Never
386400 $(KIND ) load docker-image ${IMG} --name=$(PROJECT_FULL_NAME ) -dev
387401
388402# ----------------------------------------------------------------------------------------------
0 commit comments