Skip to content

Commit

Permalink
Add MQ and Go SDK images
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurbarr committed May 15, 2018
1 parent 6775264 commit e18dcbd
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ TEST_OPTS_DOCKER ?=
MQ_IMAGE_ADVANCEDSERVER ?=mqadvanced-server:$(MQ_VERSION)-$(ARCH)-$(BASE_IMAGE_TAG)
# MQ_IMAGE_DEVSERVER is the name and tag of the built MQ Advanced for Developers image
MQ_IMAGE_DEVSERVER ?=mqadvanced-server-dev:$(MQ_VERSION)-$(ARCH)-$(BASE_IMAGE_TAG)
# MQ_IMAGE_SDK is the name and tag of the built MQ Advanced for Developers SDK image
MQ_IMAGE_SDK ?=mq-sdk:$(MQ_VERSION)-$(ARCH)-$(BASE_IMAGE_TAG)
# MQ_IMAGE_GOLANG_SDK is the name and tag of the built MQ Advanced for Developers SDK image, plus Go tools
MQ_IMAGE_GOLANG_SDK ?=mq-golang-sdk:$(MQ_VERSION)-$(ARCH)-$(BASE_IMAGE_TAG)
# DOCKER is the Docker command to run
DOCKER ?= docker
# MQ_PACKAGES specifies the MQ packages (.deb or .rpm) to install. Defaults vary on base image.
Expand Down Expand Up @@ -238,6 +242,13 @@ build-advancedserver-cover: docker-version
build-explorer: downloads/$(MQ_ARCHIVE_DEV)
$(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))

build-sdk: downloads/$(MQ_ARCHIVE) docker-version
$(call docker-build-mq,$(MQ_IMAGE_SDK),incubating/mq-sdk/Dockerfile,$(MQ_ARCHIVE_DEV),"98102d16795c4263ad9ca075190a2d4d","IBM MQ Advanced for Developers SDK (Non-Warranted)",$(MQ_VERSION))

build-golang-sdk: build-sdk
$(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_ARCHIVE),"98102d16795c4263ad9ca075190a2d4d","IBM MQ Advanced for Developers SDK (Non-Warranted)",$(MQ_VERSION))

GO_PKG_DIRS = ./cmd ./internal ./test

fmt: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS))
Expand Down
33 changes: 33 additions & 0 deletions incubating/mq-golang-sdk/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.

ARG BASE_IMAGE=mq-sdk:9.0.5.0-x86_64-ubuntu-16.04

FROM $BASE_IMAGE

ENV GO_VERSION=1.10

# Install the Go compiler and Git
RUN export DEBIAN_FRONTEND=noninteractive \
&& bash -c 'source /etc/os-release; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME} main restricted" > /etc/apt/sources.list; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME}-updates main restricted" >> /etc/apt/sources.list; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME}-backports main restricted universe" >> /etc/apt/sources.list;' \
&& apt-get update \
&& apt-get install -y --no-install-recommends golang-${GO_VERSION} git ca-certificates \
&& rm -rf /var/lib/apt/lists/*

ENV PATH="${PATH}:/usr/lib/go-${GO_VERSION}/bin"
ENV CGO_CFLAGS="-I/opt/mqm/inc/"
ENV CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"
5 changes: 5 additions & 0 deletions incubating/mq-golang-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# IBM MQ Software Developer Kit (SDK) with Go

This image contains the MQ SDK, Git, the Go compiler, and the `build-essential` package (which includes GNU C and C++ compilers plus other essential tools like `make`).

This image doesn't contain any Go code for MQ. You can add a CGO wrapper for the MQ C client, for example [mq-golang](https://github.com/ibm-messaging/mq-golang), via your vendor directory, or directly using `go get`.
33 changes: 33 additions & 0 deletions incubating/mq-sdk/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.

FROM ubuntu:16.04

# The URL to download the MQ installer from in tar.gz format
# This assumes an archive containing the MQ Debian (.deb) install packages
ARG MQ_URL

# The packages to install in install-mq.sh
ENV MQ_PACKAGES="ibmmq-sdk ibmmq-samples build-essential"

COPY install-mq.sh /usr/local/bin/

# Install MQ. To avoid a "text file busy" error here, we sleep before installing.
# Need to re-instate the `/var/mqm` directory after installation, to avoid MQ
# errors with some commands (e.g. `dspmqver`)
RUN chmod u+x /usr/local/bin/install-mq.sh \
&& sleep 1 \
&& install-mq.sh \
&& rm -rf /var/mqm \
&& /opt/mqm/bin/crtmqdir -f -s
13 changes: 13 additions & 0 deletions incubating/mq-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# IBM MQ Software Developer Kit (SDK)

This image contains the MQ SDK and the `build-essential` package, which includes GNU C and C++ compilers plus other essential tools.

## Usage

For example, you could compile the `amqsput0.c` sample program by running the following command in an SDK container:

```sh
gcc -o /tmp/amqsput0 /opt/mqm/samp/amqsput0.c -I /opt/mqm/inc -L /opt/mqm/lib64 -lmqm
```

Compiler and linker output is placed on the container's filesystem, so using multi-stage Docker builds is useful to build a final container.

0 comments on commit e18dcbd

Please sign in to comment.