From 96481068bbd6df226d90a93e2836632d750401b2 Mon Sep 17 00:00:00 2001 From: Sergio Arroutbi Date: Tue, 13 Feb 2024 11:45:58 +0100 Subject: [PATCH] Include Makefile rules for podman build This change allows controller and controller bundle generation through podman, by using next commands: ```bash make podman-build podman-push DOCKER_TAG=quay.io/{quay_user}/attestation-operator:v0.1.0 make podman-bundle DOCKER_TAG=quay.io/{quay_user_here}/attestation-operator:v0.1.0 make podman-bundle-build podman-bundle-push BUNDLE_IMG="quay.io/{quay_user}/attestation-operator-bundle:v0.1.0" ``` Resolves: #62 Signed-off-by: Sergio Arroutbi --- Makefile | 30 +++++++++++++++++++++++++++--- README.md | 12 ++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d3866c1..246b8bf 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ DOCKER_BUILDX_FLAGS ?= DOCKER_PLATFORMS ?= linux/amd64 DOCKER_NO_VERSION_TAG ?= quay.io/keylime/keylime_attestation_operator DOCKER_TAG ?= $(DOCKER_NO_VERSION_TAG):$(VERSION) +DOCKER_BIN ?= docker # helm chart version must be semver 2 compliant HELM_CHART_REPO ?= ghcr.io/keylime/helm-charts @@ -227,7 +228,7 @@ $(HELMIFY): $(LOCALBIN) .PHONY: docker-build docker-build: ## Builds the application in a docker container and creates a docker image - docker buildx build \ + $(DOCKER_BIN) buildx build \ -f $(MKFILE_DIR)/build/docker/attestation-operator/Dockerfile \ -t $(DOCKER_TAG) \ --progress=plain \ @@ -240,7 +241,17 @@ docker-build: ## Builds the application in a docker container and creates a dock .PHONY: docker-push docker-push: ## Pushes a previously built docker container - docker push $(DOCKER_TAG) + $(DOCKER_BIN) push $(DOCKER_TAG) + +##@ Podman Build + +.PHONY: podman-build +podman-build: ## Builds the application in a podman container and creates a docker image + DOCKER_BIN=podman $(MAKE) docker-build + +.PHONY: podman-push +podman-push: ## Pushes a previously built podman container + DOCKER_BIN=podman $(MAKE) docker-push helm: helm-keylime helm-crds helm-controller ## Builds all helm charts @@ -393,12 +404,25 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada .PHONY: bundle-build bundle-build: ## Build the bundle image. - docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . + $(DOCKER_BIN) build -f bundle.Dockerfile -t $(BUNDLE_IMG) . .PHONY: bundle-push bundle-push: ## Push the bundle image. $(MAKE) docker-push DOCKER_TAG=$(BUNDLE_IMG) +# Bundle generation through podman +.PHONY: podman-bundle +podman-bundle: ## Build the bundle through podman. + DOCKER_BIN=podman $(MAKE) bundle + +.PHONY: podman-bundle-build +podman-bundle-build: ## Build the bundle image through podman. + DOCKER_BIN=podman $(MAKE) bundle-build + +.PHONY: podman-bundle-push +podman-bundle-push: ## Push the bundle image through podman. + DOCKER_BIN=podman $(MAKE) bundle-push + .PHONY: opm OPM = ./bin/opm opm: ## Download opm locally if necessary. diff --git a/README.md b/README.md index fd42c18..771e7ac 100644 --- a/README.md +++ b/README.md @@ -78,15 +78,19 @@ e) `make helm-undeploy` will remove the whole deployment Operator can be deployed with operator-sdk, as it has olm/bundle support. To do so, you will need `operator-sdk` to be installed. Follow next instructions to compile, upload and deploy through operator-sdk: -* Compile controller: +* Compile controller, generate bundle and push it to registry: ```bash make docker-build docker-push DOCKER_TAG=quay.io/{quay_user}/attestation-operator:v0.1.0 -``` -* Generate bundle and push it to registry: -```bash make bundle DOCKER_TAG=quay.io/{quay_user_here}/attestation-operator:v0.1.0 make bundle-build bundle-push BUNDLE_IMG="quay.io/{quay_user}/attestation-operator-bundle:v0.1.0" ``` +It is possible to generate controller and bundle through `podman`. To do so, previous steps must be +replaced with appropriate podman rules: +```bash +make podman-build podman-push DOCKER_TAG=quay.io/{quay_user}/attestation-operator:v0.1.0 +make podman-bundle DOCKER_TAG=quay.io/{quay_user_here}/attestation-operator:v0.1.0 +make podman-bundle-build podman-bundle-push BUNDLE_IMG="quay.io/{quay_user}/attestation-operator-bundle:v0.1.0" +``` * Deploy through `operator-sdk` tool: ```bash operator-sdk run bundle quay.io/{quay_user}/attestation-operator-bundle:v0.1.0