From e03ceff7c994f13727f792b08e6b325d7f5c68ad Mon Sep 17 00:00:00 2001 From: Robert Parker Date: Thu, 23 Aug 2018 10:16:14 +0100 Subject: [PATCH] Fix dev image uid and build off rhel7 --- mq-advanced-server-rhel/go-buildah.sh | 1 + mq-advanced-server-rhel/mq-buildah.sh | 14 +++++-------- .../mq-golang-sdk-buildah.sh | 2 ++ mq-advanced-server-rhel/mqdev-buildah.sh | 3 ++- test/messaging/buildah.sh | 20 +++++++++---------- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/mq-advanced-server-rhel/go-buildah.sh b/mq-advanced-server-rhel/go-buildah.sh index e689edf..e5d25f8 100755 --- a/mq-advanced-server-rhel/go-buildah.sh +++ b/mq-advanced-server-rhel/go-buildah.sh @@ -30,5 +30,6 @@ podman run \ --env IMAGE_REVISION="$IMAGE_REVISION" \ --env IMAGE_SOURCE="$IMAGE_SOURCE" \ --env MQDEV=${dev} \ + --rm \ ${tag} \ bash -c "cd /go/src/github.com/ibm-messaging/mq-container/ && ./mq-advanced-server-rhel/go-build.sh" diff --git a/mq-advanced-server-rhel/mq-buildah.sh b/mq-advanced-server-rhel/mq-buildah.sh index 281f463..78c4527 100755 --- a/mq-advanced-server-rhel/mq-buildah.sh +++ b/mq-advanced-server-rhel/mq-buildah.sh @@ -28,7 +28,7 @@ set -e # Use a "scratch" container, so the resulting image has minimal files # Resulting image won't have yum, for example -readonly ctr_mq=$(buildah from scratch) +readonly ctr_mq=$(buildah from rhel7) readonly mnt_mq=$(buildah mount $ctr_mq) readonly archive=downloads/$1 readonly packages=$2 @@ -36,18 +36,12 @@ readonly tag=$3 readonly version=$4 readonly mqdev=$5 -# Initialize yum for use with the scratch container -rpm --root $mnt_mq --initdb - -yumdownloader --destdir=/tmp redhat-release-server -rpm --root $mnt_mq -ihv /tmp/redhat-release-server*.rpm || true - ############################################################################### # Install MQ server ############################################################################### # Install the packages required by MQ -yum install -y --installroot=${mnt_mq} --setopt install_weak_deps=false --setopt=tsflags=nodocs --setopt=override_install_langs=en_US.utf8 \ +buildah run $ctr_mq -- yum install -y --setopt install_weak_deps=false --setopt=tsflags=nodocs --setopt=override_install_langs=en_US.utf8 \ bash \ bc \ coreutils \ @@ -63,7 +57,7 @@ yum install -y --installroot=${mnt_mq} --setopt install_weak_deps=false --setopt util-linux # Clean up cached files -yum clean all --installroot=${mnt_mq} +buildah run $ctr_mq -- yum clean all rm -rf ${mnt_mq}/var/cache/yum/* # Install MQ server packages into the MQ builder image @@ -110,3 +104,5 @@ buildah config \ $ctr_mq buildah unmount $ctr_mq buildah commit $ctr_mq $tag + +buildah rm $ctr_mq diff --git a/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh b/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh index e7a7c8d..bf64669 100755 --- a/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh +++ b/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh @@ -43,3 +43,5 @@ buildah config \ --env CGO_LDFLAGS_ALLOW="-Wl,-rpath.*" \ ${ctr} buildah commit ${ctr} ${tag} + +buildah rm ${ctr} diff --git a/mq-advanced-server-rhel/mqdev-buildah.sh b/mq-advanced-server-rhel/mqdev-buildah.sh index 5e1a90c..8e4f153 100755 --- a/mq-advanced-server-rhel/mqdev-buildah.sh +++ b/mq-advanced-server-rhel/mqdev-buildah.sh @@ -37,7 +37,7 @@ readonly version=$3 useradd --root $mnt_mq --system --uid 889 --gid mqm admin groupadd --root $mnt_mq --system --gid 890 mqclient -useradd --root $mnt_mq --system --uid 890 --gid mqclient mqclient +useradd --root $mnt_mq --system --uid 890 --gid app mqclient buildah run $ctr -- echo admin:passw0rd | chpasswd @@ -79,3 +79,4 @@ buildah config \ buildah unmount $ctr_mq buildah commit $ctr_mq $tag +buildah rm $ctr_mq diff --git a/test/messaging/buildah.sh b/test/messaging/buildah.sh index 25bf922..292b4ec 100755 --- a/test/messaging/buildah.sh +++ b/test/messaging/buildah.sh @@ -22,17 +22,11 @@ set -e # Use a "scratch" container, so the resulting image has minimal files # Resulting image won't have yum, for example -readonly ctr_mq=$(buildah from scratch) +readonly ctr_mq=$(buildah from rhel7) readonly mnt_mq=$(buildah mount $ctr_mq) readonly imagename=$1 -# Initialize yum for use with the scratch container -rpm --root $mnt_mq --initdb - -yumdownloader --destdir=/tmp redhat-release-server -rpm --root $mnt_mq -ihv /tmp/redhat-release-server*.rpm || true - -yum --installroot $mnt_mq install -y \ +buildah run $ctr_mq -- yum install -y \ java-1.7.0-openjdk-devel \ java \ which \ @@ -59,9 +53,13 @@ cp $mnt_mq/usr/src/mymaven/target/lib/*.jar $mnt_mq/opt/app/ rm -rf $mnt_mq/tmp/* rm -rf $mnt_mq/usr/src/mymaven -# We can't uninstall tar or gzip because -yum --installroot $mnt_mq remove -y \ - wget +# We can't uninstall tar or gzip because they are required +buildah run $ctr_mq -- yum remove -y \ + wget + +# Clean up cached files +buildah run $ctr_mq -- yum clean all +rm -rf ${mnt_mq}/var/cache/yum/* ############################################################################### # Contain image finalization