diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 0936500..64dbdbf 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -71,7 +71,12 @@ jobs: - name: Get dependencies run: go mod download - name: Build csm-metrics-powerflex Docker Image - run: make clean build docker + 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 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: diff --git a/Makefile b/Makefile index 567768c..1982fbe 100644 --- a/Makefile +++ b/Makefile @@ -33,10 +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) - 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=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: 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