From 2305de3926de2ef8fc710ce91a2e081ccf58073d Mon Sep 17 00:00:00 2001 From: Bowen Jiang Date: Mon, 10 Jun 2024 20:25:26 +0000 Subject: [PATCH 1/5] update base image --- .github/workflows/actions.yml | 7 +++++-- Makefile | 6 +++++- scripts/build_ubi_micro.sh | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100755 scripts/build_ubi_micro.sh diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 0936500..42db864 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -71,8 +71,11 @@ jobs: - name: Get dependencies run: go mod download - name: Build csm-metrics-powerflex Docker Image - run: make clean build docker + run: | + make clean build docker + podman save csm-metrics-powerflex -o /tmp/csm-metrics-powerflex.tar + docker load -i /tmp/csm-metrics-powerflex.tar - name: Run Trivy action uses: aquasecurity/trivy-action@master with: - image-ref: csm-metrics-powerflex + image-ref: localhost/csm-metrics-powerflex diff --git a/Makefile b/Makefile index 567768c..33cbf5c 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,11 @@ download-csm-common: .PHONY: docker docker: download-csm-common $(eval include csm-common.mk) - docker build -t csm-metrics-powerflex -f Dockerfile --build-arg BASEIMAGE=$(DEFAULT_BASEIMAGE) --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) . + @echo "Building base image from $(DEFAULT_BASEIMAGE) and loading dependencies..." + ./scripts/build_ubi_micro.sh $(DEFAULT_BASEIMAGE) + @echo "Base image build: SUCCESS" + $(eval BASEIMAGE="localhost/mpfx-ubimicro:latest") + podman build -t csm-metrics-powerflex -f Dockerfile --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) . .PHONY: push push: diff --git a/scripts/build_ubi_micro.sh b/scripts/build_ubi_micro.sh new file mode 100755 index 0000000..c1aec9e --- /dev/null +++ b/scripts/build_ubi_micro.sh @@ -0,0 +1,20 @@ +# Copyright © 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) +micromount=$(buildah mount $microcontainer) +dnf install --installroot $micromount --releasever=9 --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 mpfx-ubimicro From 918412170434fe4c67822832bd5c8e8d7b19195d Mon Sep 17 00:00:00 2001 From: Bowen Jiang Date: Tue, 11 Jun 2024 17:54:04 +0000 Subject: [PATCH 2/5] update base image --- .github/workflows/actions.yml | 8 +++++--- Makefile | 11 +++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 42db864..289bf86 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -72,10 +72,12 @@ jobs: run: go mod download - name: Build csm-metrics-powerflex Docker Image run: | - make clean build docker - podman save csm-metrics-powerflex -o /tmp/csm-metrics-powerflex.tar + chmod +x ./scripts/build-ubi-micro.sh + make build-base-image + podman build -t docker.io/csm-metrics-powerflex -f ./Dockerfile --build-arg GOIMAGE=golang:latest--build-arg BASEIMAGE="localhost/mpfx-ubimicro" + podman save docker.io/library/csm-metrics-powerflex -o /tmp/csm-metrics-powerflex.tar docker load -i /tmp/csm-metrics-powerflex.tar - name: Run Trivy action uses: aquasecurity/trivy-action@master with: - image-ref: localhost/csm-metrics-powerflex + image-ref: csm-metrics-powerflex diff --git a/Makefile b/Makefile index 33cbf5c..2c70e45 100644 --- a/Makefile +++ b/Makefile @@ -33,14 +33,17 @@ test: download-csm-common: curl -O -L https://raw.githubusercontent.com/dell/csm/main/config/csm-common.mk -.PHONY: docker -docker: download-csm-common +.PHONY: build-base-image +build-base-image: download-csm-common $(eval include csm-common.mk) @echo "Building base image from $(DEFAULT_BASEIMAGE) and loading dependencies..." ./scripts/build_ubi_micro.sh $(DEFAULT_BASEIMAGE) @echo "Base image build: SUCCESS" - $(eval BASEIMAGE="localhost/mpfx-ubimicro:latest") - podman build -t csm-metrics-powerflex -f Dockerfile --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) . + $(eval BASEIMAGE="mpfx-ubimicro:latest") + +.PHONY: docker +docker: build-base-image + docker build -t csm-metrics-powerflex -f Dockerfile --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) . .PHONY: push push: From d349e4f6bfcbeaa14a5b14c2ebf01d111ae07d70 Mon Sep 17 00:00:00 2001 From: Bowen Jiang Date: Tue, 11 Jun 2024 17:57:19 +0000 Subject: [PATCH 3/5] update base image --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 289bf86..6b7c7f0 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -72,7 +72,7 @@ jobs: run: go mod download - name: Build csm-metrics-powerflex Docker Image run: | - chmod +x ./scripts/build-ubi-micro.sh + chmod +x ./scripts/build_ubi_micro.sh make build-base-image podman build -t docker.io/csm-metrics-powerflex -f ./Dockerfile --build-arg GOIMAGE=golang:latest--build-arg BASEIMAGE="localhost/mpfx-ubimicro" podman save docker.io/library/csm-metrics-powerflex -o /tmp/csm-metrics-powerflex.tar From efe3c4ad585adb93624b48330d20ce6b9a54fe02 Mon Sep 17 00:00:00 2001 From: Bowen Jiang Date: Tue, 11 Jun 2024 18:00:08 +0000 Subject: [PATCH 4/5] update base image --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 6b7c7f0..64dbdbf 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -74,7 +74,7 @@ jobs: run: | chmod +x ./scripts/build_ubi_micro.sh make build-base-image - podman build -t docker.io/csm-metrics-powerflex -f ./Dockerfile --build-arg GOIMAGE=golang:latest--build-arg BASEIMAGE="localhost/mpfx-ubimicro" + podman build -t docker.io/csm-metrics-powerflex -f ./Dockerfile --build-arg GOIMAGE=golang:latest --build-arg BASEIMAGE="localhost/mpfx-ubimicro" podman save docker.io/library/csm-metrics-powerflex -o /tmp/csm-metrics-powerflex.tar docker load -i /tmp/csm-metrics-powerflex.tar - name: Run Trivy action From 988cd9c9ab006e259cd1b9703e733d25fa8178e8 Mon Sep 17 00:00:00 2001 From: Bowen Jiang Date: Tue, 11 Jun 2024 20:50:03 +0000 Subject: [PATCH 5/5] update base image --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2c70e45..1982fbe 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ build-base-image: download-csm-common @echo "Building base image from $(DEFAULT_BASEIMAGE) and loading dependencies..." ./scripts/build_ubi_micro.sh $(DEFAULT_BASEIMAGE) @echo "Base image build: SUCCESS" - $(eval BASEIMAGE="mpfx-ubimicro:latest") + $(eval BASEIMAGE=mpfx-ubimicro:latest) .PHONY: docker docker: build-base-image