Skip to content

Commit

Permalink
MQClient Sample
Browse files Browse the repository at this point in the history
  • Loading branch information
IBMRob committed Jul 15, 2022
1 parent 36e2fe1 commit 618da61
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 3 deletions.
6 changes: 3 additions & 3 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

The samples folder contains Dockerfiles that build a sample image containing sample applications.

* [Update base package sample](updateBase/) - This sample applies updates all the base OS packages. This can be used to resolve CVEs in the base packages
* [iFix sample](applyIfix/) - This sample applies an iFix provided by IBM to an existing image.
* [MQ Client](mqclient/) - This sample adds mq client libraries to an existing image.
* [Bar sample](bars/) - This sample adds some bar files to an existing image.
* [Scripts sample](scripts/) - This sample adds scripts which are run on startup.

* [Update base package sample](updateBase/) - This sample applies updates all the base OS packages. This can be used to resolve CVEs in the base packages
* [iFix sample](applyIfix/) - This sample applies an iFix provided by IBM to an existing image.
30 changes: 30 additions & 0 deletions samples/mqclient/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ARG FROMIMAGE=cp.icr.io/cp/appc/ace:12.0.4.0-r1
FROM ${FROMIMAGE}

USER root

# The MQ packages to install - see install-mq.sh for default value
ARG MQ_URL
ARG MQ_URL_USER
ARG MQ_URL_PASS
ARG MQ_PACKAGES="MQSeriesRuntime*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesClient*.rpm"
ARG INSTALL_JRE=0

ARG MQM_UID=888

COPY install-mq.sh /usr/local/bin/
COPY install-mq-client-prereqs.sh /usr/local/bin/
# Install MQ. To avoid a "text file busy" error here, we sleep before installing.
RUN chmod u+x /usr/local/bin/install-*.sh \
&& sleep 1 \
&& install-mq-client-prereqs.sh $MQM_UID \
&& install-mq.sh $MQM_UID \
&& chown -R 1001:root /opt/mqm/* \
&& chown 1001:root /usr/local/bin/*mq* \
&& mkdir -p /var/mqm/data \
&& chown -R 1001:root /var/mqm \
&& chmod -R 777 /var/mqm

ENV MQCERTLABL=aceclient

USER 1001
28 changes: 28 additions & 0 deletions samples/mqclient/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

# Bars Sample

## What is in the sample?

- **mqclient** contains a sample dockerfile for adding the MQ client into the image.

## Building the sample

First [build the ACE image](../../README.md#Building-a-container-image) or obtain one of the shipped images.

Download a copy of the MQ redistributable client Example URL: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/9.2.0.4-IBM-MQC-Redist-LinuxX64.tar.gz

In the `sample/mqclient` folder:

```bash
docker build -t aceapp --build-arg FROMIMAGE=ace:12.0.4.0-r1 --build-arg MQ_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/9.2.0.4-IBM-MQC-Redist-LinuxX64.tar.gz --file Dockerfile .
```

## Running the sample

To run the container, launch the pod using a command such as:

```bash
`docker run -d -p 7600:7600 -p 7800:7800 -e LICENSE=accept aceapp`
```

This wll then start an IntegrationServer with a MQ Client installed.
32 changes: 32 additions & 0 deletions samples/mqclient/install-mq-client-prereqs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# -*- mode: sh -*-
# © Copyright IBM Corporation 2022
#
#
# 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.

# Fail on any non-zero return code
set -ex

test -f /usr/bin/microdnf && MICRODNF=true || MICRODNF=false
test -f /usr/bin/rpm && RPM=true || RPM=false

if ($RPM); then
EXTRA_RPMS="bash bc ca-certificates file findutils gawk glibc-common grep ncurses-compat-libs passwd procps-ng sed shadow-utils tar util-linux which"
$MICRODNF && microdnf install ${EXTRA_RPMS}
else
$MICRODNF && microdnf install findutils
fi

# Clean up cached files
$MICRODNF && microdnf clean all
109 changes: 109 additions & 0 deletions samples/mqclient/install-mq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/bin/bash
# -*- mode: sh -*-
# © Copyright IBM Corporation 2022
#
#
# 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.

# Fail on any non-zero return code
set -ex

# Download and extract the MQ files
DIR_TMP=/tmp/mq
mkdir -p ${DIR_TMP}
cd ${DIR_TMP}
if [ -z "$MQ_URL_USER" ]
then
curl -LO $MQ_URL
else
curl -LO -u ${MQ_URL_USER}:${MQ_URL_PASS} $MQ_URL
fi
tar -xzf ./*.tar.gz
rm -f ./*.tar.gz

# Check what sort of MQ package was downloaded
if [ -f "${DIR_TMP}/bin/genmqpkg.sh" ]
then
# Generate MQ package in INSTALLATION_DIR
#
# Used if the downloaded package is the MQ redistributable client. Example URL:
#
# https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/9.2.0.4-IBM-MQC-Redist-LinuxX64.tar.gz
#
echo "Detected genmqpkg.sh; installing MQ client components"
export genmqpkg_inc32=0
export genmqpkg_incadm=1
export genmqpkg_incamqp=0
export genmqpkg_incams=0
export genmqpkg_inccbl=0
export genmqpkg_inccics=0
export genmqpkg_inccpp=1
export genmqpkg_incdnet=0
export genmqpkg_incjava=1
export genmqpkg_incjre=${INSTALL_JRE}
export genmqpkg_incman=0
export genmqpkg_incmqbc=0
export genmqpkg_incmqft=0
export genmqpkg_incmqsf=0
export genmqpkg_incmqxr=0
export genmqpkg_incnls=0
export genmqpkg_incras=1
export genmqpkg_incsamp=0
export genmqpkg_incsdk=0
export genmqpkg_incserver=0
export genmqpkg_inctls=1
export genmqpkg_incunthrd=0
export genmqpkg_incweb=0
export INSTALLATION_DIR=/opt/mqm

# Install requested parts
${DIR_TMP}/bin/genmqpkg.sh -b ${INSTALLATION_DIR}

# Accept the MQ license
${INSTALLATION_DIR}/bin/mqlicense -accept
else
# Check if should try install using RPM
test -f /usr/bin/rpm && RPM=true || RPM=false
if [ ! $RPM ]; then
echo "Did not find the rpm command; cannot continue MQ client install without rpm"
exit 9
fi
#
# Used if the downloaded package is the MQ client package from FixCentral. Example URL:
#
# https://ak-delivery04-mul.dhe.ibm.com/sdfdl/v2/sar/CM/WS/0a3ih/0/Xa.2/Xb.jusyLTSp44S0BnrSUlhcQXsmOX33PXiMu_opTWF4XkF7jFZV8UxrP0RFSE0/Xc.CM/WS/0a3ih/0/9.2.0.4-IBM-MQC-LinuxX64.tar.gz/Xd./Xf.LPR.D1VK/Xg.11634360/Xi.habanero/XY.habanero/XZ.m7uIgNXpo_VTCGzC-hylOC79m0eKS5pi/9.2.0.4-IBM-MQC-LinuxX64.tar.gz
#
# Also used if the downloaded package is the full MQ developer package. Example URL:
#
# https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev924_linux_x86-64.tar.gz
#
echo "Did not find genmqpkg.sh; installing MQ client components using rpm"
$RPM && DIR_RPM=$(find ${DIR_TMP} -name "*.rpm" -printf "%h\n" | sort -u | head -1)

# Find location of mqlicense.sh
MQLICENSE=$(find ${DIR_TMP} -name "mqlicense.sh")

# Accept the MQ license
${MQLICENSE} -text_only -accept

# Install MQ using the rpm packages
$RPM && cd $DIR_RPM && rpm -ivh $MQ_PACKAGES

# Remove tar.gz files unpacked by RPM postinst scripts
find /opt/mqm -name '*.tar.gz' -delete
fi

rm -rf ${DIR_TMP}

# Create the directory for MQ configuration files
install --directory --mode 2775 --owner 1001 --group root /etc/mqm

0 comments on commit 618da61

Please sign in to comment.