Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ jobs:
echo "SKIP=true" >> $GITHUB_ENV
exit 0

- name: Set up Docker
uses: docker/setup-docker-action@v4
with:
daemon-config: |
{
"features": {
"containerd-snapshotter": true
}
}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand Down Expand Up @@ -73,9 +83,13 @@ jobs:
make reviewable
make build-docker-binary

- name: Build Images
- name: Build and push Images
run: |
IMG=ghcr.io/openmcp-project/metrics-operator:${{ env.version }} make docker-buildx docker-push

- name: Package and push helm chart
run: |
IMG=ghcr.io/openmcp-project/metrics-operator:${{ env.version }} make docker-buildx
make helm-package helm-push

- name: setup OCM
uses: open-component-model/ocm-setup-action@main
Expand Down
51 changes: 32 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
GOTESTSUM ?= $(LOCALBIN)/gotestsum
GOLANGCILINT ?= $(LOCALBIN)/golangci-lint


HELM ?= $(LOCALBIN)/helm

## Tool Versions
KUSTOMIZE_VERSION ?= v5.4.1
Expand Down Expand Up @@ -144,7 +143,7 @@ build-docker-binary: manifests generate fmt vet ## Build manager binary for Dock
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/manager-linux.amd64 cmd/main.go

.PHONY: docker-build
docker-build: build-docker-binary test ## Build docker image with the manager.
docker-build: test build-docker-binary ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .

.PHONY: docker-push
Expand All @@ -154,22 +153,14 @@ docker-push: ## Push docker image with the manager.
# 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:
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
# - be using containerd image store with docker. More Info: https://docs.docker.com/engine/storage/containerd/
# - 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

PLATFORMS ?= linux/arm64,linux/amd64

.PHONY: docker-buildx
docker-buildx: ## Build and tag docker image for each platform locally using --load
sed '1 s/^FROM/FROM --platform=$${BUILDPLATFORM}/' Dockerfile > Dockerfile.cross
$(CONTAINER_TOOL) buildx create --name project-v3-builder || true
$(CONTAINER_TOOL) buildx use project-v3-builder
@for platform in $(PLATFORMS); do \
tag="$(IMG)-$$(echo $$platform | tr / -)"; \
echo "Building $$tag for $$platform"; \
$(CONTAINER_TOOL) buildx build --platform=$$platform --tag $$tag --load -f Dockerfile.cross .; \
done
$(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.cross
docker-buildx: test
$(CONTAINER_TOOL) buildx build --platform=$(PLATFORMS) --tag $(IMG) --load -f Dockerfile .

#----------------------------------------------------------------------------------------------
##@ Deployment
Expand Down Expand Up @@ -269,14 +260,36 @@ dev-apply-metric-dynatrace-prod: ## Apply metric using Dynatrace production exam

#----------------------------------------------------------------------------------------------
##@ Helm

HELM_VERSION ?= v3.18.0
OCI_REGISTRY ?= ghcr.io/openmcp-project/charts

$(HELM): $(LOCALBIN)
@if test -x $(LOCALBIN)/helm && ! $(LOCALBIN)/helm version --short | grep -q $(HELM_VERSION); then \
echo "$(LOCALBIN)/helm version is not expected $(HELM_VERSION). Removing it before installing."; \
rm -rf $(LOCALBIN)/helm; \
fi
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 && \
mv /tmp/$(shell uname | tr '[:upper:]' '[:lower:]')-amd64/helm $(LOCALBIN)/helm && \
chmod +x $(LOCALBIN)/helm && \
rm -rf /tmp/$(shell uname | tr '[:upper:]' '[:lower:]')-amd64)

.PHONY: helm-package
helm-package: $(HELM) helm-chart ## Package the Helm chart.
$(LOCALBIN)/helm package charts/$(PROJECT_FULL_NAME)/ -d ./ --version $(shell cat VERSION)

.PHONY: helm-push
helm-push: $(HELM) ## Push the Helm chart to the OCI registry.
$(LOCALBIN)/helm push $(PROJECT_FULL_NAME)-$(shell cat VERSION).tgz oci://$(OCI_REGISTRY)

.PHONY: helm-chart
helm-chart: ## Generate Helm chart files from templates.
OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME)/Chart.yaml.tpl > charts/$(PROJECT_FULL_NAME)/Chart.yaml
OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME)/values.yaml.tpl > charts/$(PROJECT_FULL_NAME)/values.yaml

.PHONY: helm-install-local
helm-install-local: ## Install the Helm chart locally using the Docker image
helm upgrade --install $(PROJECT_FULL_NAME) charts/$(PROJECT_FULL_NAME)/ --set image.repository=$(IMG_BASE) --set image.tag=$(IMG_VERSION) --set image.pullPolicy=Never
helm-install-local: $(HELM) ## Install the Helm chart locally using the Docker image
$(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
$(KIND) load docker-image ${IMG} --name=$(PROJECT_FULL_NAME)-dev

#----------------------------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions component-constructor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ components:
type: dockermulti
repository: images/${COMPONENT_NAME}
variants:
- "${COMPONENT_REPO_PREFIX}:${VERSION}-linux-amd64"
- "${COMPONENT_REPO_PREFIX}:${VERSION}-linux-arm64"
- "${COMPONENT_REPO_PREFIX}:${VERSION}"
Loading