@@ -61,8 +61,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
6161ENVTEST ?= $(LOCALBIN ) /setup-envtest
6262GOTESTSUM ?= $(LOCALBIN ) /gotestsum
6363GOLANGCILINT ?= $(LOCALBIN ) /golangci-lint
64-
65-
64+ HELM ?= $(LOCALBIN ) /helm
6665
6766# # Tool Versions
6867KUSTOMIZE_VERSION ?= v5.4.1
@@ -144,7 +143,7 @@ build-docker-binary: manifests generate fmt vet ## Build manager binary for Dock
144143 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/manager-linux.amd64 cmd/main.go
145144
146145.PHONY : docker-build
147- docker-build : build-docker-binary test # # Build docker image with the manager.
146+ docker-build : test build-docker-binary # # Build docker image with the manager.
148147 $(CONTAINER_TOOL ) build -t ${IMG} .
149148
150149.PHONY : docker-push
@@ -154,22 +153,14 @@ docker-push: ## Push docker image with the manager.
154153# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
155154# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
156155# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
156+ # - be using containerd image store with docker. More Info: https://docs.docker.com/engine/storage/containerd/
157157# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
158- # - 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)
159- # To properly provided solutions that supports more than one platform you should use this option.
160- PLATFORMS ?= linux/arm64 linux/amd64
158+
159+ PLATFORMS ?= linux/arm64,linux/amd64
160+
161161.PHONY : docker-buildx
162- docker-buildx : # # Build and tag docker image for each platform locally using --load
163- sed ' 1 s/^FROM/FROM --platform=$${BUILDPLATFORM}/' Dockerfile > Dockerfile.cross
164- $(CONTAINER_TOOL ) buildx create --name project-v3-builder || true
165- $(CONTAINER_TOOL ) buildx use project-v3-builder
166- @for platform in $(PLATFORMS ) ; do \
167- tag=" $( IMG) -$$ (echo $$ platform | tr / -)" ; \
168- echo " Building $$ tag for $$ platform" ; \
169- $(CONTAINER_TOOL ) buildx build --platform=$$ platform --tag $$ tag --load -f Dockerfile.cross . ; \
170- done
171- $(CONTAINER_TOOL ) buildx rm project-v3-builder
172- rm Dockerfile.cross
162+ docker-buildx : test
163+ $(CONTAINER_TOOL ) buildx build --platform=$(PLATFORMS ) --tag $(IMG ) --load -f Dockerfile .
173164
174165# ----------------------------------------------------------------------------------------------
175166# #@ Deployment
@@ -269,14 +260,36 @@ dev-apply-metric-dynatrace-prod: ## Apply metric using Dynatrace production exam
269260
270261# ----------------------------------------------------------------------------------------------
271262# #@ Helm
263+
264+ HELM_VERSION ?= v3.18.0
265+ OCI_REGISTRY ?= ghcr.io/openmcp-project/charts
266+
267+ $(HELM ) : $(LOCALBIN )
268+ @if test -x $(LOCALBIN ) /helm && ! $(LOCALBIN ) /helm version --short | grep -q $(HELM_VERSION ) ; then \
269+ echo " $( LOCALBIN) /helm version is not expected $( HELM_VERSION) . Removing it before installing." ; \
270+ rm -rf $(LOCALBIN ) /helm; \
271+ fi
272+ 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 && \
273+ mv /tmp/$(shell uname | tr '[:upper:]' '[:lower:]') -amd64/helm $(LOCALBIN ) /helm && \
274+ chmod +x $(LOCALBIN ) /helm && \
275+ rm -rf /tmp/$(shell uname | tr '[:upper:]' '[:lower:]') -amd64)
276+
277+ .PHONY : helm-package
278+ helm-package : $(HELM ) helm-chart # # Package the Helm chart.
279+ $(LOCALBIN ) /helm package charts/$(PROJECT_FULL_NAME ) / -d ./ --version $(shell cat VERSION)
280+
281+ .PHONY : helm-push
282+ helm-push : $(HELM ) # # Push the Helm chart to the OCI registry.
283+ $(LOCALBIN ) /helm push $(PROJECT_FULL_NAME ) -$(shell cat VERSION) .tgz oci://$(OCI_REGISTRY )
284+
272285.PHONY : helm-chart
273286helm-chart : # # Generate Helm chart files from templates.
274287 OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME ) /Chart.yaml.tpl > charts/$(PROJECT_FULL_NAME ) /Chart.yaml
275288 OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME ) /values.yaml.tpl > charts/$(PROJECT_FULL_NAME ) /values.yaml
276289
277290.PHONY : helm-install-local
278- helm-install-local : # # Install the Helm chart locally using the Docker image
279- helm upgrade --install $(PROJECT_FULL_NAME ) charts/$(PROJECT_FULL_NAME ) / --set image.repository=$(IMG_BASE ) --set image.tag=$(IMG_VERSION ) --set image.pullPolicy=Never
291+ helm-install-local : $( HELM ) # # Install the Helm chart locally using the Docker image
292+ $( 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
280293 $(KIND ) load docker-image ${IMG} --name=$(PROJECT_FULL_NAME ) -dev
281294
282295# ----------------------------------------------------------------------------------------------
0 commit comments