From e66bcfd77f73530ce5cc63c745288565b509c792 Mon Sep 17 00:00:00 2001 From: Arthur Barr Date: Thu, 26 Jul 2018 17:09:43 +0100 Subject: [PATCH 1/5] Buildah containerized Go build --- .../mq-advanced-server-rhel/go-build.sh | 11 ++ .../mq-advanced-server-rhel/go-buildah.sh | 35 ++++++ .../install-mq-rhel.sh | 68 ++++++++++ .../mq-advanced-server-rhel/mq-buildah.sh | 116 ++++++++++++++++++ .../mq-golang-sdk-buildah.sh | 46 +++++++ 5 files changed, 276 insertions(+) create mode 100755 incubating/mq-advanced-server-rhel/go-build.sh create mode 100755 incubating/mq-advanced-server-rhel/go-buildah.sh create mode 100755 incubating/mq-advanced-server-rhel/install-mq-rhel.sh create mode 100755 incubating/mq-advanced-server-rhel/mq-buildah.sh create mode 100755 incubating/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh diff --git a/incubating/mq-advanced-server-rhel/go-build.sh b/incubating/mq-advanced-server-rhel/go-build.sh new file mode 100755 index 0000000..24ba018 --- /dev/null +++ b/incubating/mq-advanced-server-rhel/go-build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Build and test the Go code +go build ./cmd/runmqserver/ +go build ./cmd/chkmqready/ +go build ./cmd/chkmqhealthy/ +go test -v ./cmd/runmqserver/ +go test -v ./cmd/chkmqready/ +go test -v ./cmd/chkmqhealthy/ +go test -v ./internal/... +go vet ./cmd/... ./internal/... diff --git a/incubating/mq-advanced-server-rhel/go-buildah.sh b/incubating/mq-advanced-server-rhel/go-buildah.sh new file mode 100755 index 0000000..54a436f --- /dev/null +++ b/incubating/mq-advanced-server-rhel/go-buildah.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# -*- mode: sh -*- +# © Copyright IBM Corporation 2018 +# +# +# 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. + +readonly tag=$1 + +if [[ $* < 1 ]]; then + printf "Usage: $0 TAG\n" >&2 + printf "Where:\n" >&2 + printf " TAG\tTag for image containing MQ SDK and Go compiler\n" >&2 + exit 1 +fi + +# Copy the go-build.sh script into the Go builder image +install --mode 0755 go-build.sh $mnt/usr/local/bin/ +# Run the Go build script inside the Go container, mounting the source +# directory in +podman run \ + --volume ${PWD}/../..:/go/src/github.com/ibm-messaging/mq-container/ \ + --env GOPATH=/go \ + ${tag} \ + bash -c "cd /go/src/github.com/ibm-messaging/mq-container/ && ./incubating/mq-advanced-server-rhel/go-build.sh" \ No newline at end of file diff --git a/incubating/mq-advanced-server-rhel/install-mq-rhel.sh b/incubating/mq-advanced-server-rhel/install-mq-rhel.sh new file mode 100755 index 0000000..20a9b42 --- /dev/null +++ b/incubating/mq-advanced-server-rhel/install-mq-rhel.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# -*- mode: sh -*- +# © Copyright IBM Corporation 2018 +# +# +# 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. + +# Install one or more MQ components into a buildah container + +set -ex + +readonly ctr=$1 +readonly scratchmnt=$2 +readonly archive=$3 +readonly mq_packages=$4 +readonly dir_extract=/tmp/extract + +if [[ $* < 3 ]]; then + printf "Usage: $0 container mount-dir mq-archive mq-packages\n" >&2 + exit 1 +fi + +groupadd --root $scratchmnt --system --gid 888 mqm +useradd --root $scratchmnt --system --uid 888 --gid mqm mqm +usermod --root $scratchmnt -G root mqm + +if [ ! -d ${dir_extract} ]; then + mkdir -p ${dir_extract} + tar -zxvf $archive -C ${dir_extract} +fi +#DIR_RPM=$(find ${dir_extract} -name "*.rpm" -printf "%h\n" | sort -u | head -1) +#DIR_RPM=${DIR_RPM#$dir_extract} +#DIR_RPM=$(buildah run $ctr -- find ${dir_extract} -name "*.rpm" -printf "%h\n" | sort -u | head -1) +# Find location of mqlicense.sh +#MQLICENSE=$(buildah run $ctr -- find ${dir_extract} -name "mqlicense.sh") +#MQLICENSE=$(find ${dir_extract} -name "mqlicense.sh") +#MQLICENSE=${MQLICENSE#dir_extract} + +# Accept the MQ license +buildah run --volume ${dir_extract}:/mnt/mq-download $ctr -- /mnt/mq-download/MQServer/mqlicense.sh -text_only -accept + +buildah run --volume ${dir_extract}:/mnt/mq-download $ctr -- bash -c "cd /mnt/mq-download/MQServer && rpm -ivh $mq_packages" + +#rm -rf ${dir_extract} + +# Remove 32-bit libraries from 64-bit container +find $scratchmnt/opt/mqm $scratchmnt/var/mqm -type f -exec file {} \; | awk -F: '/ELF 32-bit/{print $1}' | xargs --no-run-if-empty rm -f + +# Remove tar.gz files unpacked by RPM postinst scripts +find $scratchmnt/opt/mqm -name '*.tar.gz' -delete + +# Recommended: Set the default MQ installation (makes the MQ commands available on the PATH) +buildah run $ctr -- /opt/mqm/bin/setmqinst -p /opt/mqm -i + +# Optional: Set these values for the IBM Cloud Vulnerability Report +sed -i 's/PASS_MAX_DAYS\t99999/PASS_MAX_DAYS\t90/' $scratchmnt/etc/login.defs +sed -i 's/PASS_MIN_DAYS\t0/PASS_MIN_DAYS\t1/' $scratchmnt/etc/login.defs +sed -i 's/password\t\[success=1 default=ignore\]\tpam_unix\.so obscure sha512/password\t[success=1 default=ignore]\tpam_unix.so obscure sha512 minlen=8/' $scratchmnt/etc/pam.d/password-auth diff --git a/incubating/mq-advanced-server-rhel/mq-buildah.sh b/incubating/mq-advanced-server-rhel/mq-buildah.sh new file mode 100755 index 0000000..e5b92a5 --- /dev/null +++ b/incubating/mq-advanced-server-rhel/mq-buildah.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# -*- mode: sh -*- +# © Copyright IBM Corporation 2018 +# +# +# 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. + +# Build a RHEL image, using the buildah tool + +set -x +set -e + +MQ_ARCHIVE=downloads/mqadv_dev910_linux_x86-64.tar.gz + +############################################################################### +# Setup MQ server working container +############################################################################### + +# 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 mnt_mq=$(buildah mount $ctr_mq) + +# Initialize yum for use with the scratch container +rpm --root $mnt_mq --initdb + +# TODO: eek +yum install yum-utils +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} --releasever 7 --setopt install_weak_deps=false --setopt=tsflags=nodocs --setopt=override_install_langs=en_US.utf8 \ + bash \ + bc \ + coreutils \ + file \ + findutils \ + gawk \ + glibc-common \ + grep \ + passwd \ + procps-ng \ + sed \ + tar \ + util-linux + +# Clean up cached files +yum clean all --installroot=${mnt_mq} --releasever 7 +rm -rf ${mnt_mq}/var/cache/yum/* + +# Install MQ server packages into the MQ builder image +./install-mq-rhel.sh ${ctr_mq} "${mnt_mq}" "${MQ_ARCHIVE}" "MQSeriesRuntime-*.rpm MQSeriesServer-*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesMsg*.rpm MQSeriesSamples*.rpm MQSeriesAMS-*.rpm" + +# Remove the directory structure under /var/mqm which was created by the installer +rm -rf ${mnt_mq}/var/mqm + +# Create the mount point for volumes +mkdir -p ${mnt_mq}/mnt/mqm + +# Create the directory for MQ configuration files +mkdir -p ${mnt_mq}/etc/mqm + +# Create a symlink for /var/mqm -> /mnt/mqm/data +buildah run $ctr ln -s /mnt/mqm/data /var/mqm + +# Install the Go binaries into the image +install --mode 0750 --owner 888 --group 888 ../../runmqserver ${mnt_mq}/usr/local/bin/ +install --mode 6750 --owner 888 --group 888 ../../chk* ${mnt_mq}/usr/local/bin/ +install --mode 0750 --owner 888 --group 888 ../../NOTICES.txt ${mnt_mq}/opt/mqm/licenses/notices-container.txt +# cp runmqserver $mnt_mq/usr/local/bin/ +# cp chkmq* $mnt_mq/usr/local/bin/ +# cp NOTICES.txt $mnt_mq/opt/mqm/licenses/notices-container.txt +# chmod ug+x $mnt_mq/usr/local/bin/runmqserver +# chown mqm:mqm $mnt_mq/usr/local/bin/*mq* +# chmod ug+xs $mnt_mq/usr/local/bin/chkmq* + +############################################################################### +# Final Buildah commands +############################################################################### + +buildah config \ + --port 1414/tcp \ + --port 9157/tcp \ + --os linux \ + --label architecture=x86_64 \ + --label io.openshift.tags="mq messaging" \ + --label io.k8s.display-name="IBM MQ Advanced Server" \ + --label io.k8s.description="IBM MQ is messaging middleware that simplifies and accelerates the integration of diverse applications and business data across multiple platforms. It uses message queues to facilitate the exchanges of information and offers a single messaging solution for cloud, mobile, Internet of Things (IoT) and on-premises environments." \ + --label name="mqadvanced-server" \ + --label vendor="IBM" \ + --label version="9.1.0.0" \ + --env AMQ_ADDITIONAL_JSON_LOG=1 \ + --env LANG=en_US.UTF-8 \ + --env LOG_FORMAT=basic \ + --entrypoint runmqserver \ + --user 888 \ + $ctr_mq +buildah unmount $ctr_mq +buildah commit $ctr_mq mymq + +# TODO: Leaves the working container lying around. Good for dev. \ No newline at end of file diff --git a/incubating/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh b/incubating/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh new file mode 100755 index 0000000..1c07892 --- /dev/null +++ b/incubating/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# -*- mode: sh -*- +# © Copyright IBM Corporation 2018 +# +# +# 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. + +# Build a RHEL image for building Go programs which use MQ + +set -ex +readonly mq_archive=downloads/mqadv_dev910_linux_x86-64.tar.gz +# Use plain RHEL 7 container +# Note: Red Hat's devtools/go-toolset-7-rhel7 image doesn't allow use of 'root' +# user required for installing the MQ SDK +readonly ctr=$(buildah from rhel7) +readonly mnt=$(buildah mount $ctr) +readonly tag=mq-golang-sdk +# Enable Yum repository for "optional" RPMs, which is needed for "golang" +buildah run ${ctr} -- yum-config-manager --enable rhel-7-server-optional-rpms +# Install Go compiler +buildah run ${ctr} -- yum install -y golang git gcc +# Install the MQ SDK into the Go builder image +./install-mq-rhel.sh ${ctr} "${mnt}" "${mq_archive}" "MQSeriesRuntime-*.rpm MQSeriesSDK-*.rpm" +# Clean up Yum files +buildah run ${ctr} -- yum clean all --releasever 7 +rm -rf ${mnt}/var/cache/yum/* +buildah unmount ${ctr} +# Set environment variables for MQ/Go compilation +buildah config \ + --os linux \ + --env CGO_CFLAGS="-I/opt/mqm/inc/" \ + --env CGO_LDFLAGS_ALLOW="-Wl,-rpath.*" \ + ${ctr} +buildah commit ${ctr} ${tag} + + From a2d3abfb86e1a7693a22d0f0fdc3112a427a5053 Mon Sep 17 00:00:00 2001 From: Arthur Barr Date: Tue, 7 Aug 2018 09:31:50 +0100 Subject: [PATCH 2/5] Minor fixes to buildah build --- .../mq-advanced-server-rhel/go-build.sh | 11 -- .../mq-advanced-server-rhel/go-buildah.sh | 35 ------ .../install-mq-rhel.sh | 68 ---------- .../mq-advanced-server-rhel/mq-buildah.sh | 116 ------------------ .../mq-golang-sdk-buildah.sh | 46 ------- 5 files changed, 276 deletions(-) delete mode 100755 incubating/mq-advanced-server-rhel/go-build.sh delete mode 100755 incubating/mq-advanced-server-rhel/go-buildah.sh delete mode 100755 incubating/mq-advanced-server-rhel/install-mq-rhel.sh delete mode 100755 incubating/mq-advanced-server-rhel/mq-buildah.sh delete mode 100755 incubating/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh diff --git a/incubating/mq-advanced-server-rhel/go-build.sh b/incubating/mq-advanced-server-rhel/go-build.sh deleted file mode 100755 index 24ba018..0000000 --- a/incubating/mq-advanced-server-rhel/go-build.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Build and test the Go code -go build ./cmd/runmqserver/ -go build ./cmd/chkmqready/ -go build ./cmd/chkmqhealthy/ -go test -v ./cmd/runmqserver/ -go test -v ./cmd/chkmqready/ -go test -v ./cmd/chkmqhealthy/ -go test -v ./internal/... -go vet ./cmd/... ./internal/... diff --git a/incubating/mq-advanced-server-rhel/go-buildah.sh b/incubating/mq-advanced-server-rhel/go-buildah.sh deleted file mode 100755 index 54a436f..0000000 --- a/incubating/mq-advanced-server-rhel/go-buildah.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# -*- mode: sh -*- -# © Copyright IBM Corporation 2018 -# -# -# 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. - -readonly tag=$1 - -if [[ $* < 1 ]]; then - printf "Usage: $0 TAG\n" >&2 - printf "Where:\n" >&2 - printf " TAG\tTag for image containing MQ SDK and Go compiler\n" >&2 - exit 1 -fi - -# Copy the go-build.sh script into the Go builder image -install --mode 0755 go-build.sh $mnt/usr/local/bin/ -# Run the Go build script inside the Go container, mounting the source -# directory in -podman run \ - --volume ${PWD}/../..:/go/src/github.com/ibm-messaging/mq-container/ \ - --env GOPATH=/go \ - ${tag} \ - bash -c "cd /go/src/github.com/ibm-messaging/mq-container/ && ./incubating/mq-advanced-server-rhel/go-build.sh" \ No newline at end of file diff --git a/incubating/mq-advanced-server-rhel/install-mq-rhel.sh b/incubating/mq-advanced-server-rhel/install-mq-rhel.sh deleted file mode 100755 index 20a9b42..0000000 --- a/incubating/mq-advanced-server-rhel/install-mq-rhel.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# -*- mode: sh -*- -# © Copyright IBM Corporation 2018 -# -# -# 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. - -# Install one or more MQ components into a buildah container - -set -ex - -readonly ctr=$1 -readonly scratchmnt=$2 -readonly archive=$3 -readonly mq_packages=$4 -readonly dir_extract=/tmp/extract - -if [[ $* < 3 ]]; then - printf "Usage: $0 container mount-dir mq-archive mq-packages\n" >&2 - exit 1 -fi - -groupadd --root $scratchmnt --system --gid 888 mqm -useradd --root $scratchmnt --system --uid 888 --gid mqm mqm -usermod --root $scratchmnt -G root mqm - -if [ ! -d ${dir_extract} ]; then - mkdir -p ${dir_extract} - tar -zxvf $archive -C ${dir_extract} -fi -#DIR_RPM=$(find ${dir_extract} -name "*.rpm" -printf "%h\n" | sort -u | head -1) -#DIR_RPM=${DIR_RPM#$dir_extract} -#DIR_RPM=$(buildah run $ctr -- find ${dir_extract} -name "*.rpm" -printf "%h\n" | sort -u | head -1) -# Find location of mqlicense.sh -#MQLICENSE=$(buildah run $ctr -- find ${dir_extract} -name "mqlicense.sh") -#MQLICENSE=$(find ${dir_extract} -name "mqlicense.sh") -#MQLICENSE=${MQLICENSE#dir_extract} - -# Accept the MQ license -buildah run --volume ${dir_extract}:/mnt/mq-download $ctr -- /mnt/mq-download/MQServer/mqlicense.sh -text_only -accept - -buildah run --volume ${dir_extract}:/mnt/mq-download $ctr -- bash -c "cd /mnt/mq-download/MQServer && rpm -ivh $mq_packages" - -#rm -rf ${dir_extract} - -# Remove 32-bit libraries from 64-bit container -find $scratchmnt/opt/mqm $scratchmnt/var/mqm -type f -exec file {} \; | awk -F: '/ELF 32-bit/{print $1}' | xargs --no-run-if-empty rm -f - -# Remove tar.gz files unpacked by RPM postinst scripts -find $scratchmnt/opt/mqm -name '*.tar.gz' -delete - -# Recommended: Set the default MQ installation (makes the MQ commands available on the PATH) -buildah run $ctr -- /opt/mqm/bin/setmqinst -p /opt/mqm -i - -# Optional: Set these values for the IBM Cloud Vulnerability Report -sed -i 's/PASS_MAX_DAYS\t99999/PASS_MAX_DAYS\t90/' $scratchmnt/etc/login.defs -sed -i 's/PASS_MIN_DAYS\t0/PASS_MIN_DAYS\t1/' $scratchmnt/etc/login.defs -sed -i 's/password\t\[success=1 default=ignore\]\tpam_unix\.so obscure sha512/password\t[success=1 default=ignore]\tpam_unix.so obscure sha512 minlen=8/' $scratchmnt/etc/pam.d/password-auth diff --git a/incubating/mq-advanced-server-rhel/mq-buildah.sh b/incubating/mq-advanced-server-rhel/mq-buildah.sh deleted file mode 100755 index e5b92a5..0000000 --- a/incubating/mq-advanced-server-rhel/mq-buildah.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# -*- mode: sh -*- -# © Copyright IBM Corporation 2018 -# -# -# 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. - -# Build a RHEL image, using the buildah tool - -set -x -set -e - -MQ_ARCHIVE=downloads/mqadv_dev910_linux_x86-64.tar.gz - -############################################################################### -# Setup MQ server working container -############################################################################### - -# 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 mnt_mq=$(buildah mount $ctr_mq) - -# Initialize yum for use with the scratch container -rpm --root $mnt_mq --initdb - -# TODO: eek -yum install yum-utils -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} --releasever 7 --setopt install_weak_deps=false --setopt=tsflags=nodocs --setopt=override_install_langs=en_US.utf8 \ - bash \ - bc \ - coreutils \ - file \ - findutils \ - gawk \ - glibc-common \ - grep \ - passwd \ - procps-ng \ - sed \ - tar \ - util-linux - -# Clean up cached files -yum clean all --installroot=${mnt_mq} --releasever 7 -rm -rf ${mnt_mq}/var/cache/yum/* - -# Install MQ server packages into the MQ builder image -./install-mq-rhel.sh ${ctr_mq} "${mnt_mq}" "${MQ_ARCHIVE}" "MQSeriesRuntime-*.rpm MQSeriesServer-*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesMsg*.rpm MQSeriesSamples*.rpm MQSeriesAMS-*.rpm" - -# Remove the directory structure under /var/mqm which was created by the installer -rm -rf ${mnt_mq}/var/mqm - -# Create the mount point for volumes -mkdir -p ${mnt_mq}/mnt/mqm - -# Create the directory for MQ configuration files -mkdir -p ${mnt_mq}/etc/mqm - -# Create a symlink for /var/mqm -> /mnt/mqm/data -buildah run $ctr ln -s /mnt/mqm/data /var/mqm - -# Install the Go binaries into the image -install --mode 0750 --owner 888 --group 888 ../../runmqserver ${mnt_mq}/usr/local/bin/ -install --mode 6750 --owner 888 --group 888 ../../chk* ${mnt_mq}/usr/local/bin/ -install --mode 0750 --owner 888 --group 888 ../../NOTICES.txt ${mnt_mq}/opt/mqm/licenses/notices-container.txt -# cp runmqserver $mnt_mq/usr/local/bin/ -# cp chkmq* $mnt_mq/usr/local/bin/ -# cp NOTICES.txt $mnt_mq/opt/mqm/licenses/notices-container.txt -# chmod ug+x $mnt_mq/usr/local/bin/runmqserver -# chown mqm:mqm $mnt_mq/usr/local/bin/*mq* -# chmod ug+xs $mnt_mq/usr/local/bin/chkmq* - -############################################################################### -# Final Buildah commands -############################################################################### - -buildah config \ - --port 1414/tcp \ - --port 9157/tcp \ - --os linux \ - --label architecture=x86_64 \ - --label io.openshift.tags="mq messaging" \ - --label io.k8s.display-name="IBM MQ Advanced Server" \ - --label io.k8s.description="IBM MQ is messaging middleware that simplifies and accelerates the integration of diverse applications and business data across multiple platforms. It uses message queues to facilitate the exchanges of information and offers a single messaging solution for cloud, mobile, Internet of Things (IoT) and on-premises environments." \ - --label name="mqadvanced-server" \ - --label vendor="IBM" \ - --label version="9.1.0.0" \ - --env AMQ_ADDITIONAL_JSON_LOG=1 \ - --env LANG=en_US.UTF-8 \ - --env LOG_FORMAT=basic \ - --entrypoint runmqserver \ - --user 888 \ - $ctr_mq -buildah unmount $ctr_mq -buildah commit $ctr_mq mymq - -# TODO: Leaves the working container lying around. Good for dev. \ No newline at end of file diff --git a/incubating/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh b/incubating/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh deleted file mode 100755 index 1c07892..0000000 --- a/incubating/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# -*- mode: sh -*- -# © Copyright IBM Corporation 2018 -# -# -# 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. - -# Build a RHEL image for building Go programs which use MQ - -set -ex -readonly mq_archive=downloads/mqadv_dev910_linux_x86-64.tar.gz -# Use plain RHEL 7 container -# Note: Red Hat's devtools/go-toolset-7-rhel7 image doesn't allow use of 'root' -# user required for installing the MQ SDK -readonly ctr=$(buildah from rhel7) -readonly mnt=$(buildah mount $ctr) -readonly tag=mq-golang-sdk -# Enable Yum repository for "optional" RPMs, which is needed for "golang" -buildah run ${ctr} -- yum-config-manager --enable rhel-7-server-optional-rpms -# Install Go compiler -buildah run ${ctr} -- yum install -y golang git gcc -# Install the MQ SDK into the Go builder image -./install-mq-rhel.sh ${ctr} "${mnt}" "${mq_archive}" "MQSeriesRuntime-*.rpm MQSeriesSDK-*.rpm" -# Clean up Yum files -buildah run ${ctr} -- yum clean all --releasever 7 -rm -rf ${mnt}/var/cache/yum/* -buildah unmount ${ctr} -# Set environment variables for MQ/Go compilation -buildah config \ - --os linux \ - --env CGO_CFLAGS="-I/opt/mqm/inc/" \ - --env CGO_LDFLAGS_ALLOW="-Wl,-rpath.*" \ - ${ctr} -buildah commit ${ctr} ${tag} - - From 8fcdfeb1c4b9c9734b829a308b07b9a1aacf56f7 Mon Sep 17 00:00:00 2001 From: Robert Parker Date: Mon, 20 Aug 2018 11:25:05 +0100 Subject: [PATCH 3/5] Move and rename files for RHEL build --- Makefile | 85 ------------------- mq-advanced-server-rhel/ansible/.gitignore | 1 + .../ansible/rhel-build.yaml | 33 +++++++ mq-advanced-server-rhel/go-build.sh | 52 ++---------- 4 files changed, 42 insertions(+), 129 deletions(-) delete mode 100644 Makefile create mode 100644 mq-advanced-server-rhel/ansible/.gitignore create mode 100644 mq-advanced-server-rhel/ansible/rhel-build.yaml diff --git a/Makefile b/Makefile deleted file mode 100644 index 73e6fe4..0000000 --- a/Makefile +++ /dev/null @@ -1,85 +0,0 @@ -# © Copyright IBM Corporation 2018 -# -# 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. - -############################################################################### -# Build targets -############################################################################### - -# default to building UBUNTU as this was the default for the previous Makefile -.PHONY: build-devserver -build-devserver: build-devserver-ubuntu - -.PHONY: build-advancedserver -build-advancedserver: build-advancedserver-ubuntu - -.PHONY: test-devserver -test-devserver: test-devserver-ubuntu - -.PHONY: test-advancedserver -test-advancedserver: test-advancedserver-ubuntu - -.PHONY: deps -deps: deps-ubuntu - -.PHONY: lint -lint: lint-ubuntu - -# UBUNTU building targets -.PHONY: build-devserver-ubuntu -build-devserver-ubuntu: - $(MAKE) -f Makefile-UBUNTU build-devserver - -.PHONY: test-devserver-ubuntu -test-devserver-ubuntu: - $(MAKE) -f Makefile-UBUNTU test-devserver - -.PHONY: build-devjmstest -build-devjmstest: - $(MAKE) -f Makefile-UBUNTU build-devjmstest - -.PHONY: build-devjmstest-ubuntu - $(MAKE) -f Makefile-UBUNTU build-devjmstest - -.PHONY: build-advancedserver-ubuntu -build-advancedserver-ubuntu: - $(MAKE) -f Makefile-UBUNTU build-advancedserver - -.PHONY: test-advancedserver-ubuntu -test-advancedserver-ubuntu: - $(MAKE) -f Makefile-UBUNTU test-advancedserver - -.PHONY: deps-ubuntu -deps-ubuntu: - $(MAKE) -f Makefile-UBUNTU deps - -.PHONY: lint-ubuntu -lint-ubuntu: - $(MAKE) -f Makefile-UBUNTU lint - -# RHEL building targets -.PHONY: build-devserver-rhel -build-devserver-rhel: - $(MAKE) -f Makefile-RHEL build-devserver - -.PHONY: test-devserver-rhel -test-devserver-rhel: - $(MAKE) -f Makefile-RHEL test-devserver - -.PHONY: build-advancedserver-rhel -build-advancedserver-rhel: - $(MAKE) -f Makefile-RHEL build-advancedserver - -.PHONY: test-advancedserver-rhel -test-advancedserver-rhel: - $(MAKE) -f Makefile-RHEL test-advancedserver diff --git a/mq-advanced-server-rhel/ansible/.gitignore b/mq-advanced-server-rhel/ansible/.gitignore new file mode 100644 index 0000000..9b0b900 --- /dev/null +++ b/mq-advanced-server-rhel/ansible/.gitignore @@ -0,0 +1 @@ +hosts \ No newline at end of file diff --git a/mq-advanced-server-rhel/ansible/rhel-build.yaml b/mq-advanced-server-rhel/ansible/rhel-build.yaml new file mode 100644 index 0000000..76e2240 --- /dev/null +++ b/mq-advanced-server-rhel/ansible/rhel-build.yaml @@ -0,0 +1,33 @@ +# © Copyright IBM Corporation 2018 +# +# 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. +--- +# Sets up a server for building the Red Hat image. +- hosts: rhbuild + become: true + any_errors_fatal: true + tasks: + - name: install buildah + package: + name: buildah + state: present + when: ansible_distribution == "RedHat" + - name: install podman + package: + name: buildah + state: present + when: ansible_distribution == "RedHat" + - name: install make + package: + name: make + state: present diff --git a/mq-advanced-server-rhel/go-build.sh b/mq-advanced-server-rhel/go-build.sh index 831ba41..24ba018 100755 --- a/mq-advanced-server-rhel/go-build.sh +++ b/mq-advanced-server-rhel/go-build.sh @@ -1,47 +1,11 @@ #!/bin/bash -# -*- mode: sh -*- -# © Copyright IBM Corporation 2018 -# -# -# 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. - -# Builds and tests the golang programs used by the MQ image. - -set -e - -cd $GOPATH/src/github.com/ibm-messaging/mq-container/ # Build and test the Go code -mkdir -p build -cd build - -rm -f chkmqready chkmqhealthy runmqserver runmqdevserver - -if [ "$MQDEV" = "TRUE" ]; then - # Build and test the Go code - go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\"" --tags 'mqdev' ../cmd/runmqserver/ - go build ../cmd/runmqdevserver/ -else - go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\"" ../cmd/runmqserver/ -fi - -go build ../cmd/chkmqready/ -go build ../cmd/chkmqhealthy/ -go test -v ../cmd/runmqserver/ -go test -v ../cmd/chkmqready/ -go test -v ../cmd/chkmqhealthy/ -if [ "$MQDEV" = "TRUE" ]; then - go test -v ../cmd/runmqdevserver -fi -go test -v ../internal/... -go vet ../cmd/... ../internal/... +go build ./cmd/runmqserver/ +go build ./cmd/chkmqready/ +go build ./cmd/chkmqhealthy/ +go test -v ./cmd/runmqserver/ +go test -v ./cmd/chkmqready/ +go test -v ./cmd/chkmqhealthy/ +go test -v ./internal/... +go vet ./cmd/... ./internal/... From 9e04bfc68aefdc404755c11a47c212a92041f22e Mon Sep 17 00:00:00 2001 From: Robert Parker Date: Mon, 20 Aug 2018 11:29:42 +0100 Subject: [PATCH 4/5] Create MQ RHEL buildah build --- Makefile | 85 +++++++++++++++++++ mq-advanced-server-rhel/ansible/.gitignore | 1 - .../ansible/rhel-build.yaml | 33 ------- mq-advanced-server-rhel/go-build.sh | 52 ++++++++++-- 4 files changed, 129 insertions(+), 42 deletions(-) create mode 100644 Makefile delete mode 100644 mq-advanced-server-rhel/ansible/.gitignore delete mode 100644 mq-advanced-server-rhel/ansible/rhel-build.yaml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..73e6fe4 --- /dev/null +++ b/Makefile @@ -0,0 +1,85 @@ +# © Copyright IBM Corporation 2018 +# +# 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. + +############################################################################### +# Build targets +############################################################################### + +# default to building UBUNTU as this was the default for the previous Makefile +.PHONY: build-devserver +build-devserver: build-devserver-ubuntu + +.PHONY: build-advancedserver +build-advancedserver: build-advancedserver-ubuntu + +.PHONY: test-devserver +test-devserver: test-devserver-ubuntu + +.PHONY: test-advancedserver +test-advancedserver: test-advancedserver-ubuntu + +.PHONY: deps +deps: deps-ubuntu + +.PHONY: lint +lint: lint-ubuntu + +# UBUNTU building targets +.PHONY: build-devserver-ubuntu +build-devserver-ubuntu: + $(MAKE) -f Makefile-UBUNTU build-devserver + +.PHONY: test-devserver-ubuntu +test-devserver-ubuntu: + $(MAKE) -f Makefile-UBUNTU test-devserver + +.PHONY: build-devjmstest +build-devjmstest: + $(MAKE) -f Makefile-UBUNTU build-devjmstest + +.PHONY: build-devjmstest-ubuntu + $(MAKE) -f Makefile-UBUNTU build-devjmstest + +.PHONY: build-advancedserver-ubuntu +build-advancedserver-ubuntu: + $(MAKE) -f Makefile-UBUNTU build-advancedserver + +.PHONY: test-advancedserver-ubuntu +test-advancedserver-ubuntu: + $(MAKE) -f Makefile-UBUNTU test-advancedserver + +.PHONY: deps-ubuntu +deps-ubuntu: + $(MAKE) -f Makefile-UBUNTU deps + +.PHONY: lint-ubuntu +lint-ubuntu: + $(MAKE) -f Makefile-UBUNTU lint + +# RHEL building targets +.PHONY: build-devserver-rhel +build-devserver-rhel: + $(MAKE) -f Makefile-RHEL build-devserver + +.PHONY: test-devserver-rhel +test-devserver-rhel: + $(MAKE) -f Makefile-RHEL test-devserver + +.PHONY: build-advancedserver-rhel +build-advancedserver-rhel: + $(MAKE) -f Makefile-RHEL build-advancedserver + +.PHONY: test-advancedserver-rhel +test-advancedserver-rhel: + $(MAKE) -f Makefile-RHEL test-advancedserver diff --git a/mq-advanced-server-rhel/ansible/.gitignore b/mq-advanced-server-rhel/ansible/.gitignore deleted file mode 100644 index 9b0b900..0000000 --- a/mq-advanced-server-rhel/ansible/.gitignore +++ /dev/null @@ -1 +0,0 @@ -hosts \ No newline at end of file diff --git a/mq-advanced-server-rhel/ansible/rhel-build.yaml b/mq-advanced-server-rhel/ansible/rhel-build.yaml deleted file mode 100644 index 76e2240..0000000 --- a/mq-advanced-server-rhel/ansible/rhel-build.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# © Copyright IBM Corporation 2018 -# -# 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. ---- -# Sets up a server for building the Red Hat image. -- hosts: rhbuild - become: true - any_errors_fatal: true - tasks: - - name: install buildah - package: - name: buildah - state: present - when: ansible_distribution == "RedHat" - - name: install podman - package: - name: buildah - state: present - when: ansible_distribution == "RedHat" - - name: install make - package: - name: make - state: present diff --git a/mq-advanced-server-rhel/go-build.sh b/mq-advanced-server-rhel/go-build.sh index 24ba018..831ba41 100755 --- a/mq-advanced-server-rhel/go-build.sh +++ b/mq-advanced-server-rhel/go-build.sh @@ -1,11 +1,47 @@ #!/bin/bash +# -*- mode: sh -*- +# © Copyright IBM Corporation 2018 +# +# +# 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. + +# Builds and tests the golang programs used by the MQ image. + +set -e + +cd $GOPATH/src/github.com/ibm-messaging/mq-container/ # Build and test the Go code -go build ./cmd/runmqserver/ -go build ./cmd/chkmqready/ -go build ./cmd/chkmqhealthy/ -go test -v ./cmd/runmqserver/ -go test -v ./cmd/chkmqready/ -go test -v ./cmd/chkmqhealthy/ -go test -v ./internal/... -go vet ./cmd/... ./internal/... +mkdir -p build +cd build + +rm -f chkmqready chkmqhealthy runmqserver runmqdevserver + +if [ "$MQDEV" = "TRUE" ]; then + # Build and test the Go code + go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\"" --tags 'mqdev' ../cmd/runmqserver/ + go build ../cmd/runmqdevserver/ +else + go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\"" ../cmd/runmqserver/ +fi + +go build ../cmd/chkmqready/ +go build ../cmd/chkmqhealthy/ +go test -v ../cmd/runmqserver/ +go test -v ../cmd/chkmqready/ +go test -v ../cmd/chkmqhealthy/ +if [ "$MQDEV" = "TRUE" ]; then + go test -v ../cmd/runmqdevserver +fi +go test -v ../internal/... +go vet ../cmd/... ../internal/... From aa04229d857c145e5994402ba0899e436a997f42 Mon Sep 17 00:00:00 2001 From: Robert Parker Date: Mon, 20 Aug 2018 15:44:36 +0100 Subject: [PATCH 5/5] Call correct make target when using default make targets --- Makefile | 108 +++++++++++++++++++++++++++++++++++++++++------- Makefile-RHEL | 4 +- Makefile-UBUNTU | 37 +++-------------- 3 files changed, 99 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index 73e6fe4..cd0e45f 100644 --- a/Makefile +++ b/Makefile @@ -12,28 +12,72 @@ # See the License for the specific language governing permissions and # limitations under the License. +############################################################################### +# Variables +############################################################################### +GO_PKG_DIRS = ./cmd ./internal ./test + +BASE_OS = $(shell cat /etc/*-release | grep ID=) +ifeq "$(findstring ubuntu,$(BASE_OS))" "ubuntu" + BASE_OS=UBUNTU +else ifeq "$(findstring rhel,$(BASE_OS))" "rhel" + BASE_OS=RHEL +else + BASE_OS=UNKNOWN +endif + + + ############################################################################### # Build targets ############################################################################### # default to building UBUNTU as this was the default for the previous Makefile .PHONY: build-devserver +ifeq ($(BASE_OS),UBUNTU) build-devserver: build-devserver-ubuntu +else ifeq ($(BASE_OS),RHEL) +build-devserver: build-devserver-rhel +else +build-devserver: unknownos +endif .PHONY: build-advancedserver +ifeq ($(BASE_OS),UBUNTU) build-advancedserver: build-advancedserver-ubuntu +else ifeq ($(BASE_OS),RHEL) +build-advancedserver: build-advancedserver-rhel +else +build-advancedserver: unknownos +endif + .PHONY: test-devserver +ifeq ($(BASE_OS),UBUNTU) test-devserver: test-devserver-ubuntu +else ifeq ($(BASE_OS),RHEL) +test-devserver: test-devserver-rhel +else +test-devserver: unknownos +endif .PHONY: test-advancedserver +ifeq ($(BASE_OS),UBUNTU) test-advancedserver: test-advancedserver-ubuntu +else ifeq ($(BASE_OS),RHEL) +test-advancedserver: test-advancedserver-rhel +else +test-advancedserver: unknownos +endif -.PHONY: deps -deps: deps-ubuntu - -.PHONY: lint -lint: lint-ubuntu +.PHONY: build-devjmstest +ifeq ($(BASE_OS),UBUNTU) +build-devjmstest: build-devjmstest-ubuntu +else ifeq ($(BASE_OS),RHEL) +build-devjmstest: build-devjmstest-rhel +else +build-devjmstest: unknownos +endif # UBUNTU building targets .PHONY: build-devserver-ubuntu @@ -44,10 +88,6 @@ build-devserver-ubuntu: test-devserver-ubuntu: $(MAKE) -f Makefile-UBUNTU test-devserver -.PHONY: build-devjmstest -build-devjmstest: - $(MAKE) -f Makefile-UBUNTU build-devjmstest - .PHONY: build-devjmstest-ubuntu $(MAKE) -f Makefile-UBUNTU build-devjmstest @@ -59,13 +99,9 @@ build-advancedserver-ubuntu: test-advancedserver-ubuntu: $(MAKE) -f Makefile-UBUNTU test-advancedserver -.PHONY: deps-ubuntu -deps-ubuntu: - $(MAKE) -f Makefile-UBUNTU deps - -.PHONY: lint-ubuntu -lint-ubuntu: - $(MAKE) -f Makefile-UBUNTU lint +.PHONY: build-devjmstest-ubuntu +build-devjmstest-ubuntu: + $(MAKE) -f Makefile-UBUNTU build-devjmstest # RHEL building targets .PHONY: build-devserver-rhel @@ -83,3 +119,43 @@ build-advancedserver-rhel: .PHONY: test-advancedserver-rhel test-advancedserver-rhel: $(MAKE) -f Makefile-RHEL test-advancedserver + +.PHONY: build-devjmstest-rhel +build-devjmstest-rhel: + $(MAKE) -f Makefile-RHEL build-devjmstest + +# Common targets +.PHONY: clean +clean: + rm -rf ./coverage + rm -rf ./build + rm -rf ./deps + +.PHONY: deps +deps: + glide install --strip-vendor + +.PHONY: build-cov +build-cov: + mkdir -p build + cd build; go test -c -covermode=count ../cmd/runmqserver + +.PHONY: precommit +precommit: fmt lint + +.PHONY: fmt +fmt: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS)) + go fmt $(addsuffix /..., $(GO_PKG_DIRS)) + +.PHONY: lint +lint: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS)) + @# This expression is necessary because /... includes the vendor directory in golint + @# As of 11/04/2018 there is an open issue to fix it: https://github.com/golang/lint/issues/320 + golint -set_exit_status $(sort $(dir $(wildcard $(addsuffix /*/*.go, $(GO_PKG_DIRS))))) + +.PHONY: unknownos +unknownos: + $(info $(SPACER)$(shell printf "ERROR: Unknown OS ("$(BASE_OS)") please run specific make targets"$(END))) + exit 1 + +include formatting.mk diff --git a/Makefile-RHEL b/Makefile-RHEL index 4efa6cb..90d7da0 100644 --- a/Makefile-RHEL +++ b/Makefile-RHEL @@ -107,12 +107,12 @@ check-prereqs: .PHONY: test-advancedserver -test-advancedserver: +test-advancedserver: $(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_ADVANCEDSERVER) on $(shell docker --version)"$(END))) .PHONY: test-devserver -test-devserver: +test-devserver: $(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_DEVSERVER) on $(shell docker --version)"$(END))) diff --git a/Makefile-UBUNTU b/Makefile-UBUNTU index 4250d73..a24847a 100644 --- a/Makefile-UBUNTU +++ b/Makefile-UBUNTU @@ -110,24 +110,15 @@ default: build-devserver test all: build-devserver build-advancedserver .PHONY: test-all -test-all: test-devserver test-advancedserver - -.PHONY: precommit -precommit: fmt lint all test-all +test-all: build-devjmstest test-devserver test-advancedserver .PHONY: devserver -devserver: build-devserver test-devserver +devserver: build-devserver build-devjmstest test-devserver # Build incubating components .PHONY: incubating incubating: build-explorer -.PHONY: clean -clean: - rm -rf ./coverage - rm -rf ./build - rm -rf ./deps - downloads/$(MQ_ARCHIVE_DEV): $(info $(SPACER)$(shell printf $(TITLE)"Downloading IBM MQ Advanced for Developers "$(MQ_VERSION)$(END))) mkdir -p downloads @@ -141,19 +132,10 @@ downloads/$(MQ_SDK_ARCHIVE): .PHONY: downloads downloads: downloads/$(MQ_ARCHIVE_DEV) downloads/$(MQ_SDK_ARCHIVE) -.PHONY: deps -deps: - glide install --strip-vendor - # Vendor Go dependencies for the Docker tests test/docker/vendor: cd test/docker && dep ensure -vendor-only -.PHONY: build-cov -build-cov: - mkdir -p build - cd build; go test -c -covermode=count ../cmd/runmqserver - # Shortcut to just run the unit tests .PHONY: test-unit test-unit: @@ -259,8 +241,8 @@ build-devserver: downloads/$(MQ_ARCHIVE_DEV) docker-version build-golang-sdk-ex build-advancedserver-cover: docker-version $(DOCKER) build --build-arg BASE_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER) -t $(MQ_IMAGE_ADVANCEDSERVER)-cover -f Dockerfile-server.cover . -.PHONY: build-explorer docker-pull -build-explorer: downloads/$(MQ_ARCHIVE_DEV) +.PHONY: build-explorer +build-explorer: downloads/$(MQ_ARCHIVE_DEV) docker-pull $(call docker-build-mq,mq-explorer:latest-$(ARCH),incubating/mq-explorer/Dockerfile-mq-explorer,$(MQ_ARCHIVE_DEV),"98102d16795c4263ad9ca075190a2d4d","IBM MQ Advanced for Developers (Non-Warranted)",$(MQ_VERSION)) .PHONY: build-sdk @@ -283,17 +265,8 @@ build-golang-sdk-ex: docker-version build-sdk-ex $(DOCKER) build --build-arg BASE_IMAGE=$(MQ_IMAGE_SDK) -t $(MQ_IMAGE_GOLANG_SDK) -f incubating/mq-golang-sdk/Dockerfile . # $(call docker-build-mq,$(MQ_IMAGE_GOLANG_SDK),incubating/mq-golang-sdk/Dockerfile,$(MQ_IMAGE_SDK),"98102d16795c4263ad9ca075190a2d4d","IBM MQ Advanced for Developers SDK (Non-Warranted)",$(MQ_VERSION)) +.PHONY: docker-pull docker-pull: $(DOCKER) pull $(BASE_IMAGE) -GO_PKG_DIRS = ./cmd ./internal ./test - -fmt: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS)) - go fmt $(addsuffix /..., $(GO_PKG_DIRS)) - -lint: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS)) - @# This expression is necessary because /... includes the vendor directory in golint - @# As of 11/04/2018 there is an open issue to fix it: https://github.com/golang/lint/issues/320 - golint -set_exit_status $(sort $(dir $(wildcard $(addsuffix /*/*.go, $(GO_PKG_DIRS))))) - include formatting.mk