diff --git a/Dockerfile.podman b/Dockerfile.podman index a3ea5da..1d2c338 100644 --- a/Dockerfile.podman +++ b/Dockerfile.podman @@ -10,24 +10,16 @@ RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -ldflags '-extldflags "-stati # Print the version RUN go run core/semver/semver.go -f mk + # Dockerfile to build Unity CSI Driver -# Tag corresponding to digest ab03679e683010d485ef0399e056b09a38d7843ba4a36ee7dec337dd0037f7a7 is 8.7-1085 -FROM registry.access.redhat.com/ubi8/ubi-minimal@sha256:ab03679e683010d485ef0399e056b09a38d7843ba4a36ee7dec337dd0037f7a7 as driver -# dependencies, following by cleaning the cache -RUN microdnf update -y \ - && \ - microdnf install -y e2fsprogs xfsprogs nfs-utils device-mapper-multipath hostname \ - && \ - microdnf clean all \ - && \ - rm -rf /var/cache/run +# Fetching the base ubi micro image with the require packges committed using buildah +FROM localhost/csiunity-ubimicro as driver + COPY --from=builder /go/src/csi-unity/bin/csi-unity / COPY csi-unity/scripts/run.sh / RUN chmod 777 /run.sh ENTRYPOINT ["/run.sh"] -RUN microdnf install -y tar - # final stage FROM driver as final diff --git a/build.sh b/build.sh index e6b88f9..f7f8d2a 100644 --- a/build.sh +++ b/build.sh @@ -29,6 +29,7 @@ function git_version { } function build_image { + bash build_ubi_micro.sh registry.access.redhat.com/ubi8/ubi-micro echo $BUILDCMD build -t ${IMAGE_NAME}:${IMAGE_TAG} . (cd .. && $BUILDCMD build -t ${IMAGE_NAME}:${IMAGE_TAG} --build-arg GOPROXY=$GOPROXY -f csi-unity/Dockerfile.podman . --format=docker) echo $BUILDCMD tag ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_REPO}/${IMAGE_REPO_NAMESPACE}/${IMAGE_NAME}:${IMAGE_TAG} diff --git a/build_ubi_micro.sh b/build_ubi_micro.sh new file mode 100644 index 0000000..db1c223 --- /dev/null +++ b/build_ubi_micro.sh @@ -0,0 +1,7 @@ +#!/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/ e2fsprogs which xfsprogs nfs-utils device-mapper-multipath util-linux hostname -y +dnf clean all --installroot $micromount +buildah umount $microcontainer +buildah commit $microcontainer csiunity-ubimicro