From 4509327f78f8217ff0be9f2d0774f2e5af02b2b6 Mon Sep 17 00:00:00 2001 From: Rodrigo Bassil Date: Mon, 10 Jun 2024 19:55:36 +0000 Subject: [PATCH 1/2] Updating ubi micro dependencies --- .github/workflows/actions.yml | 10 ++++++++-- Makefile | 24 ++++++++++++++---------- scripts/build-ubi-micro.sh | 8 ++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 scripts/build-ubi-micro.sh diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 948be4915..202965ba1 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -114,11 +114,17 @@ jobs: - name: Checkout the code uses: actions/checkout@v4 - name: Build Docker Images - run: DEFAULT_IMG=csm-operator:latest make -o gen-semver docker-build + run: | + chmod +x ./scripts/build-ubi-micro.sh + make build-base-image + make -o gen-semver + podman build -t docker.io/csm-operator -f ./Dockerfile --build-arg GOIMAGE=golang:latest --build-arg BASEIMAGE="localhost/csm-operator-ubimicro" + podman save docker.io/library/csm-operator -o /tmp/csm-operator.tar + docker load -i /tmp/csm-operator.tar - name: Scan controller Image uses: Azure/container-scan@v0 env: DOCKLE_HOST: "unix:///var/run/docker.sock" with: - image-name: csm-operator:latest + image-name: csm-operator severity-threshold: HIGH diff --git a/Makefile b/Makefile index 656832f7b..c2f9278f4 100644 --- a/Makefile +++ b/Makefile @@ -95,13 +95,11 @@ build: gen-semver fmt vet ## Build manager binary. run: generate gen-semver fmt vet static-manifests ## Run a controller from your host. go run ./main.go -podman-build: gen-semver download-csm-common ## Build podman image with the manager. - $(eval include csm-common.mk) - podman build . -t ${DEFAULT_IMG} --build-arg BASEIMAGE=$(DEFAULT_BASEIMAGE) --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) +podman-build: gen-semver build-base-image ## Build podman image with the manager. + podman build . -t ${DEFAULT_IMG} --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) -docker-build: gen-semver download-csm-common ## Build docker image with the manager. - $(eval include csm-common.mk) - docker build . -t ${DEFAULT_IMG} --build-arg BASEIMAGE=$(DEFAULT_BASEIMAGE) --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) +docker-build: gen-semver build-base-image ## Build docker image with the manager. + docker build . -t ${DEFAULT_IMG} --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) docker-push: docker-build ## Builds, tags and pushes docker image with the manager. docker tag ${DEFAULT_IMG} ${IMG} @@ -166,9 +164,9 @@ bundle: static-manifests gen-semver kustomize ## Generate bundle manifests and m operator-sdk bundle validate ./bundle .PHONY: bundle-build -bundle-build: gen-semver download-csm-common ## Build the bundle image. - $(eval include csm-common.mk) - docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) --build-arg BASEIMAGE=$(DEFAULT_BASEIMAGE) . +bundle-build: gen-semver build-base-image ## Build the bundle image. + docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) --build-arg BASEIMAGE=$(BASEIMAGE) . + .PHONY: bundle-push bundle-push: gen-semver ## Push the bundle image. @@ -217,7 +215,13 @@ catalog-push: gen-semver ## Push a catalog image. lint: build golangci-lint run --fix +.PHONY: build-base-image +build-base-image: download-csm-common + $(eval include csm-common.mk) + sh ./scripts/build-ubi-micro.sh $(DEFAULT_BASEIMAGE) + $(eval BASEIMAGE=csm-operator-ubimicro:latest) + # Download common CSM configuration file used for builds .PHONY: download-csm-common download-csm-common: - curl -O -L https://raw.githubusercontent.com/dell/csm/main/config/csm-common.mk + curl -O -L https://raw.githubusercontent.com/dell/csm/main/config/csm-common.mk \ No newline at end of file diff --git a/scripts/build-ubi-micro.sh b/scripts/build-ubi-micro.sh new file mode 100644 index 000000000..05999a61e --- /dev/null +++ b/scripts/build-ubi-micro.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +microcontainer=$(buildah from $1) +micromount=$(buildah mount $microcontainer) +dnf install --installroot $micromount --releasever=8 --nodocs --setopt install_weak_deps=false --setopt=reposdir=/etc/yum.repos.d/ rpm -y +dnf clean all --installroot $micromount +buildah umount $microcontainer +buildah commit $microcontainer csm-operator-ubimicro \ No newline at end of file From a8dafa5f9bc573b0dfc6c642b464d740a6f520c4 Mon Sep 17 00:00:00 2001 From: Rodrigo Bassil Date: Mon, 10 Jun 2024 20:35:49 +0000 Subject: [PATCH 2/2] Updating ubi micro dependencies --- scripts/build-ubi-micro.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/build-ubi-micro.sh b/scripts/build-ubi-micro.sh index 05999a61e..dfc037544 100644 --- a/scripts/build-ubi-micro.sh +++ b/scripts/build-ubi-micro.sh @@ -1,3 +1,18 @@ +#!/bin/sh +# Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + #!/bin/bash microcontainer=$(buildah from $1)