Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f000ff891 | ||
|
|
e33710eb00 | ||
|
|
2fdd2c51ff | ||
|
|
b73ad12011 | ||
|
|
b276e0b4ef | ||
|
|
a3c0af9648 | ||
|
|
1208a5d08b | ||
|
|
fe8a87b39f | ||
|
|
9a34e9b15c | ||
|
|
78ce84b3a1 | ||
|
|
6d11b0d8ae | ||
|
|
d0fce28ef3 | ||
|
|
31f604cc47 | ||
|
|
c6a921efee | ||
|
|
822a073c4e | ||
|
|
a854c4c627 | ||
|
|
3989661778 | ||
|
|
9a7d44fef6 | ||
|
|
f73347a9cf | ||
|
|
ad1b2db1fd | ||
|
|
11b94de1c0 | ||
|
|
1906896038 | ||
|
|
d5ec1fa505 | ||
|
|
e03ceff7c9 | ||
|
|
64f5ce3624 | ||
|
|
b921bb82d3 | ||
|
|
92e57f2cb1 | ||
|
|
0281e52b47 | ||
|
|
8bdba41f75 | ||
|
|
aa04229d85 | ||
|
|
9e04bfc68a | ||
|
|
8fcdfeb1c4 | ||
|
|
a2d3abfb86 | ||
|
|
e66bcfd77f | ||
|
|
d2ea8d4f06 | ||
|
|
fc19776c04 | ||
|
|
3f07b1e77f | ||
|
|
00568adc6d | ||
|
|
ba1b4f8ef9 | ||
|
|
9b98555886 | ||
|
|
dbfc47591e | ||
|
|
b087f37505 | ||
|
|
08299dd0d1 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -7,3 +7,8 @@ build
|
|||||||
coverage
|
coverage
|
||||||
downloads
|
downloads
|
||||||
incubating/mqipt/ms81*
|
incubating/mqipt/ms81*
|
||||||
|
vendor/github.com/prometheus/client_model/bin/
|
||||||
|
vendor/github.com/prometheus/client_model/.classpath
|
||||||
|
vendor/github.com/prometheus/client_model/.project
|
||||||
|
vendor/github.com/prometheus/client_model/.settings*
|
||||||
|
gosec_results.json
|
||||||
|
|||||||
26
.travis.yml
26
.travis.yml
@@ -29,8 +29,7 @@ cache:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
- BASE_IMAGE=ubuntu:16.04
|
- BASE_IMAGE=ubuntu:16.04
|
||||||
# Commented out temporarily until Issue 166 is resolved
|
- BASE_IMAGE=centos:latest
|
||||||
# - BASE_IMAGE=centos:latest
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
@@ -46,24 +45,29 @@ jobs:
|
|||||||
- env: DOCKER_DOWNGRADE="echo nothing to be done"
|
- env: DOCKER_DOWNGRADE="echo nothing to be done"
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
- ./install-build-deps-ubuntu.sh
|
||||||
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
|
||||||
- sudo apt-get update
|
|
||||||
- sudo apt-get -y install docker-ce
|
|
||||||
- curl https://glide.sh/get | sh
|
|
||||||
- sudo curl -Lo /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64
|
|
||||||
- sudo chmod +x /usr/local/bin/dep
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- echo nothing
|
- echo nothing
|
||||||
|
|
||||||
script:
|
before_script:
|
||||||
|
- echo 'Downloading Go dependencies...' && echo -en 'travis_fold:start:deps\\r'
|
||||||
- make deps
|
- make deps
|
||||||
|
- echo -en 'travis_fold:end:deps\\r'
|
||||||
|
- echo 'Building Developer image...' && echo -en 'travis_fold:start:build-devserver\\r'
|
||||||
- make build-devserver
|
- make build-devserver
|
||||||
|
- echo -en 'travis_fold:end:build-devserver\\r'
|
||||||
|
- echo 'Building Developer JMS test image...' && echo -en 'travis_fold:start:build-devjmstest\\r'
|
||||||
- make build-devjmstest
|
- make build-devjmstest
|
||||||
|
- echo -en 'travis_fold:end:build-devjmstest\\r'
|
||||||
|
|
||||||
|
script:
|
||||||
|
- echo 'Downgrading Docker (if necessary)...' && echo -en 'travis_fold:start:docker-downgrade\\r'
|
||||||
- eval "$DOCKER_DOWNGRADE"
|
- eval "$DOCKER_DOWNGRADE"
|
||||||
|
- echo -en 'travis_fold:end:docker-downgrade\\r'
|
||||||
|
- echo 'Testing Developer image...' && echo -en 'travis_fold:start:test-devserver\\r'
|
||||||
- make test-devserver
|
- make test-devserver
|
||||||
|
- echo -en 'travis_fold:end:test-devserver\\r'
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- go get golang.org/x/lint/golint
|
|
||||||
- make lint
|
- make lint
|
||||||
|
|||||||
16
CHANGELOG.md
16
CHANGELOG.md
@@ -1,5 +1,21 @@
|
|||||||
# Change log
|
# Change log
|
||||||
|
|
||||||
|
## 9.1.1.0 (2018-11-30)
|
||||||
|
|
||||||
|
* Updated to MQ version 9.1.1.0
|
||||||
|
* Created seperate RedHat Makefile for building images on RedHat machines with buildah
|
||||||
|
* Enabled REST messaging capability for app user.
|
||||||
|
* Added support for container suplimentary groups
|
||||||
|
* Removed IBM MQ version 9.0.5 details.
|
||||||
|
* Added additional Diagnostics ([#203](https://github.com/ibm-messaging/mq-container/pull/203))
|
||||||
|
* Implementted GOSec to perform code scans for security vulnerabilities. (([#227](https://github.com/ibm-messaging/mq-container/pull/227)))
|
||||||
|
* Removed Queue manager create option from the MQ Console.
|
||||||
|
* Fixes for the following issues:
|
||||||
|
* Check explicitly for `/mnt/mqm` ([#175](https://github.com/ibm-messaging/mq-container/pull/175))
|
||||||
|
* Force string output in chkmqhealthy ([#174](https://github.com/ibm-messaging/mq-container/pull/174))
|
||||||
|
* Use -aG not -G when adding a group for a user
|
||||||
|
* Security fixes for libsystemd0 systemd systemd-sysv & libudev1
|
||||||
|
|
||||||
## 9.1.0.0 (2018-07-23)
|
## 9.1.0.0 (2018-07-23)
|
||||||
|
|
||||||
* Updated to MQ version 9.1.0.0
|
* Updated to MQ version 9.1.0.0
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
ARG BASE_IMAGE=ubuntu:16.04
|
ARG BASE_IMAGE=ubuntu:16.04
|
||||||
ARG BUILDER_IMAGE=mq-golang-sdk:9.0.5.0-x86_64-ubuntu-16.04
|
ARG BUILDER_IMAGE=mq-golang-sdk:9.1.1.0-x86_64-ubuntu-16.04
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Build stage to build Go code
|
# Build stage to build Go code
|
||||||
@@ -21,12 +21,11 @@ ARG BUILDER_IMAGE=mq-golang-sdk:9.0.5.0-x86_64-ubuntu-16.04
|
|||||||
FROM $BUILDER_IMAGE as builder
|
FROM $BUILDER_IMAGE as builder
|
||||||
WORKDIR /go/src/github.com/ibm-messaging/mq-container/
|
WORKDIR /go/src/github.com/ibm-messaging/mq-container/
|
||||||
ARG IMAGE_REVISION="Not specified"
|
ARG IMAGE_REVISION="Not specified"
|
||||||
ARG IMAGE_CREATED="Not specified"
|
|
||||||
ARG IMAGE_SOURCE="Not specified"
|
ARG IMAGE_SOURCE="Not specified"
|
||||||
COPY cmd/ ./cmd
|
COPY cmd/ ./cmd
|
||||||
COPY internal/ ./internal
|
COPY internal/ ./internal
|
||||||
COPY vendor/ ./vendor
|
COPY vendor/ ./vendor
|
||||||
RUN go build -ldflags "-X \"main.ImageCreated=$IMAGE_CREATED\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\"" ./cmd/runmqserver/
|
RUN go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\"" ./cmd/runmqserver/
|
||||||
RUN go build ./cmd/chkmqready/
|
RUN go build ./cmd/chkmqready/
|
||||||
RUN go build ./cmd/chkmqhealthy/
|
RUN go build ./cmd/chkmqhealthy/
|
||||||
# Run all unit tests
|
# Run all unit tests
|
||||||
|
|||||||
369
Makefile
369
Makefile
@@ -1,4 +1,4 @@
|
|||||||
# © Copyright IBM Corporation 2017, 2018
|
# © Copyright IBM Corporation 2018
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -13,290 +13,163 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Conditional variables - you can override the values of these variables from
|
# Variables
|
||||||
# the command line
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# BASE_IMAGE is the base image to use for MQ, for example "ubuntu" or "rhel"
|
GO_PKG_DIRS = ./cmd ./internal ./test
|
||||||
BASE_IMAGE ?= ubuntu:16.04
|
|
||||||
# MQ_VERSION is the fully qualified MQ version number to build
|
|
||||||
MQ_VERSION ?= 9.1.0.0
|
|
||||||
# MQ_ARCHIVE is the name of the file, under the downloads directory, from which MQ Advanced can
|
|
||||||
# be installed. The default value is derived from MQ_VERSION, BASE_IMAGE and architecture
|
|
||||||
# Does not apply to MQ Advanced for Developers.
|
|
||||||
MQ_ARCHIVE ?= IBM_MQ_$(MQ_VERSION)_$(MQ_ARCHIVE_TYPE)_$(MQ_ARCHIVE_ARCH).tar.gz
|
|
||||||
# MQ_ARCHIVE_DEV is the name of the file, under the downloads directory, from which MQ Advanced
|
|
||||||
# for Developers can be installed
|
|
||||||
MQ_ARCHIVE_DEV ?= $(MQ_ARCHIVE_DEV_$(MQ_VERSION))
|
|
||||||
# MQ_SDK_ARCHIVE specifies the archive to use for building the golang programs. Defaults vary on developer or advanced.
|
|
||||||
MQ_SDK_ARCHIVE ?= $(MQ_ARCHIVE_DEV_$(MQ_VERSION))
|
|
||||||
# Options to `go test` for the Docker tests
|
|
||||||
TEST_OPTS_DOCKER ?=
|
|
||||||
# MQ_IMAGE_ADVANCEDSERVER is the name and tag of the built MQ Advanced image
|
|
||||||
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.
|
|
||||||
MQ_PACKAGES ?=
|
|
||||||
|
|
||||||
###############################################################################
|
# Set variable if running on a Red Hat Enterprise Linux host
|
||||||
# Other variables
|
ifneq ($(wildcard /etc/redhat-release),)
|
||||||
###############################################################################
|
REDHAT_RELEASE = $(shell cat /etc/redhat-release)
|
||||||
# ARCH is the platform architecture (e.g. x86_64, ppc64le or s390x)
|
ifeq "$(findstring Red Hat,$(REDHAT_RELEASE))" "Red Hat"
|
||||||
ARCH = $(shell uname -m)
|
RHEL_HOST = "true"
|
||||||
# BUILD_SERVER_CONTAINER is the name of the web server container used at build time
|
|
||||||
BUILD_SERVER_CONTAINER=build-server
|
|
||||||
# NUM_CPU is the number of CPUs available to Docker. Used to control how many
|
|
||||||
# test run in parallel
|
|
||||||
NUM_CPU = $(or $(shell docker info --format "{{ .NCPU }}"),2)
|
|
||||||
# BASE_IMAGE_TAG is a normalized version of BASE_IMAGE, suitable for use in a Docker tag
|
|
||||||
BASE_IMAGE_TAG=$(subst /,-,$(subst :,-,$(BASE_IMAGE)))
|
|
||||||
MQ_IMAGE_DEVSERVER_BASE=mqadvanced-server-dev-base:$(MQ_VERSION)-$(ARCH)-$(BASE_IMAGE_TAG)
|
|
||||||
# Docker image name to use for JMS tests
|
|
||||||
DEV_JMS_IMAGE=mq-dev-jms-test
|
|
||||||
# Variables for versioning
|
|
||||||
IMAGE_REVISION=$(shell git rev-parse HEAD)
|
|
||||||
IMAGE_SOURCE=$(shell git config --get remote.origin.url)
|
|
||||||
IMAGE_CREATED=$(shell date -u +%Y-%m-%dT%H:%M:%S%:z)
|
|
||||||
|
|
||||||
|
|
||||||
ifneq (,$(findstring Microsoft,$(shell uname -r)))
|
|
||||||
DOWNLOADS_DIR=$(patsubst /mnt/c%,C:%,$(realpath ./downloads/))
|
|
||||||
else
|
|
||||||
DOWNLOADS_DIR=$(realpath ./downloads/)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Try to figure out which archive to use from the BASE_IMAGE
|
|
||||||
ifeq "$(findstring ubuntu,$(BASE_IMAGE))" "ubuntu"
|
|
||||||
MQ_ARCHIVE_TYPE=UBUNTU
|
|
||||||
MQ_ARCHIVE_DEV_PLATFORM=ubuntu
|
|
||||||
else
|
|
||||||
MQ_ARCHIVE_TYPE=LINUX
|
|
||||||
MQ_ARCHIVE_DEV_PLATFORM=linux
|
|
||||||
endif
|
endif
|
||||||
# Try to figure out which archive to use from the architecture
|
|
||||||
ifeq "$(ARCH)" "x86_64"
|
|
||||||
MQ_ARCHIVE_ARCH=X86-64
|
|
||||||
MQ_DEV_ARCH=x86-64
|
|
||||||
else ifeq "$(ARCH)" "ppc64le"
|
|
||||||
MQ_ARCHIVE_ARCH=LE_POWER
|
|
||||||
MQ_DEV_ARCH=ppcle
|
|
||||||
else ifeq "$(ARCH)" "s390x"
|
|
||||||
MQ_ARCHIVE_ARCH=SYSTEM_Z
|
|
||||||
MQ_DEV_ARCH=s390x
|
|
||||||
endif
|
|
||||||
# Archive names for IBM MQ Advanced for Developers
|
|
||||||
MQ_ARCHIVE_DEV_9.0.5.0=mqadv_dev905_$(MQ_ARCHIVE_DEV_PLATFORM)_x86-64.tar.gz
|
|
||||||
MQ_ARCHIVE_DEV_9.1.0.0=mqadv_dev910_$(MQ_ARCHIVE_DEV_PLATFORM)_$(MQ_DEV_ARCH).tar.gz
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Build targets
|
# Build targets
|
||||||
###############################################################################
|
###############################################################################
|
||||||
.PHONY: vars
|
|
||||||
vars:
|
|
||||||
#ifeq "$(findstring ubuntu,$(BASE_IMAGE))","ubuntu"
|
|
||||||
@echo $(MQ_ARCHIVE_ARCH)
|
|
||||||
@echo $(MQ_ARCHIVE_TYPE)
|
|
||||||
@echo $(MQ_ARCHIVE)
|
|
||||||
|
|
||||||
.PHONY: default
|
# Targets default to a RHEL image on a RHEL host, or an Ubuntu image everywhere else
|
||||||
default: build-devserver test
|
|
||||||
|
|
||||||
# Build all components (except incubating ones)
|
.PHONY: build-devserver
|
||||||
.PHONY: all
|
ifdef RHEL_HOST
|
||||||
all: build-devserver build-advancedserver
|
build-devserver: build-devserver-rhel
|
||||||
|
else
|
||||||
|
build-devserver: build-devserver-ubuntu
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: test-all
|
.PHONY: build-advancedserver
|
||||||
test-all: test-devserver test-advancedserver
|
ifdef RHEL_HOST
|
||||||
|
build-advancedserver: build-advancedserver-rhel
|
||||||
|
else
|
||||||
|
build-advancedserver: build-advancedserver-ubuntu
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: precommit
|
|
||||||
precommit: fmt lint all test-all
|
|
||||||
|
|
||||||
.PHONY: devserver
|
.PHONY: test-devserver
|
||||||
devserver: build-devserver test-devserver
|
ifdef RHEL_HOST
|
||||||
|
test-devserver: test-devserver-rhel
|
||||||
|
else
|
||||||
|
test-devserver: test-devserver-ubuntu
|
||||||
|
endif
|
||||||
|
|
||||||
# Build incubating components
|
.PHONY: test-advancedserver
|
||||||
.PHONY: incubating
|
ifdef RHEL_HOST
|
||||||
incubating: build-explorer
|
test-advancedserver: test-advancedserver-rhel
|
||||||
|
else
|
||||||
|
test-advancedserver: test-advancedserver-ubuntu
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: build-devjmstest
|
||||||
|
ifdef RHEL_HOST
|
||||||
|
build-devjmstest: build-devjmstest-rhel
|
||||||
|
else
|
||||||
|
build-devjmstest: build-devjmstest-ubuntu
|
||||||
|
endif
|
||||||
|
|
||||||
|
# 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-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: build-devjmstest-ubuntu
|
||||||
|
build-devjmstest-ubuntu:
|
||||||
|
$(MAKE) -f Makefile-UBUNTU build-devjmstest
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
.PHONY: build-devjmstest-rhel
|
||||||
|
build-devjmstest-rhel:
|
||||||
|
$(MAKE) -f Makefile-RHEL build-devjmstest
|
||||||
|
|
||||||
|
# Common targets
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf ./coverage
|
rm -rf ./coverage
|
||||||
rm -rf ./build
|
rm -rf ./build
|
||||||
rm -rf ./deps
|
rm -rf ./deps
|
||||||
|
|
||||||
downloads/$(MQ_ARCHIVE_DEV):
|
|
||||||
$(info $(SPACER)$(shell printf $(TITLE)"Downloading IBM MQ Advanced for Developers "$(MQ_VERSION)$(END)))
|
|
||||||
mkdir -p downloads
|
|
||||||
cd downloads; curl -LO https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/$(MQ_ARCHIVE_DEV)
|
|
||||||
|
|
||||||
downloads/$(MQ_SDK_ARCHIVE):
|
|
||||||
$(info $(SPACER)$(shell printf $(TITLE)"Downloading IBM MQ Advanced for Developers "$(MQ_VERSION)$(END)))
|
|
||||||
mkdir -p downloads
|
|
||||||
cd downloads; curl -LO https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/$(MQ_SDK_ARCHIVE)
|
|
||||||
|
|
||||||
.PHONY: downloads
|
|
||||||
downloads: downloads/$(MQ_ARCHIVE_DEV) downloads/$(MQ_SDK_ARCHIVE)
|
|
||||||
|
|
||||||
.PHONY: deps
|
.PHONY: deps
|
||||||
deps:
|
deps:
|
||||||
glide install --strip-vendor
|
glide install --strip-vendor
|
||||||
|
|
||||||
# Vendor Go dependencies for the Docker tests
|
|
||||||
test/docker/vendor:
|
|
||||||
cd test/docker && dep ensure -vendor-only
|
|
||||||
|
|
||||||
.PHONY: build-cov
|
.PHONY: build-cov
|
||||||
build-cov:
|
build-cov:
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build; go test -c -covermode=count ../cmd/runmqserver
|
cd build; go test -c -covermode=count ../cmd/runmqserver
|
||||||
|
|
||||||
# Shortcut to just run the unit tests
|
.PHONY: precommit
|
||||||
.PHONY: test-unit
|
precommit: fmt lint
|
||||||
test-unit:
|
|
||||||
docker build --target builder --file Dockerfile-server .
|
|
||||||
|
|
||||||
.PHONY: test-advancedserver
|
|
||||||
test-advancedserver: test/docker/vendor
|
|
||||||
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_ADVANCEDSERVER) on $(shell docker --version)"$(END)))
|
|
||||||
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER) EXPECTED_LICENSE=Production go test -parallel $(NUM_CPU) $(TEST_OPTS_DOCKER)
|
|
||||||
|
|
||||||
.PHONY: build-devjmstest
|
|
||||||
build-devjmstest:
|
|
||||||
$(info $(SPACER)$(shell printf $(TITLE)"Build JMS tests for developer config"$(END)))
|
|
||||||
cd test/messaging && docker build --tag $(DEV_JMS_IMAGE) .
|
|
||||||
|
|
||||||
.PHONY: test-devserver
|
|
||||||
test-devserver: test/docker/vendor
|
|
||||||
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_DEVSERVER) on $(shell docker --version)"$(END)))
|
|
||||||
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_DEVSERVER) EXPECTED_LICENSE=Developer DEV_JMS_IMAGE=$(DEV_JMS_IMAGE) go test -parallel $(NUM_CPU) -tags mqdev $(TEST_OPTS_DOCKER)
|
|
||||||
|
|
||||||
coverage:
|
|
||||||
mkdir coverage
|
|
||||||
|
|
||||||
.PHONY: test-advancedserver-cover
|
|
||||||
test-advancedserver-cover: test/docker/vendor coverage
|
|
||||||
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_ADVANCEDSERVER) with code coverage on $(shell docker --version)"$(END)))
|
|
||||||
rm -f ./coverage/unit*.cov
|
|
||||||
# Run unit tests with coverage, for each package under 'internal'
|
|
||||||
go list -f '{{.Name}}' ./internal/... | xargs -I {} go test -cover -covermode count -coverprofile ./coverage/unit-{}.cov ./internal/{}
|
|
||||||
# ls -1 ./cmd | xargs -I {} go test -cover -covermode count -coverprofile ./coverage/unit-{}.cov ./cmd/{}/...
|
|
||||||
echo 'mode: count' > ./coverage/unit.cov
|
|
||||||
tail -q -n +2 ./coverage/unit-*.cov >> ./coverage/unit.cov
|
|
||||||
go tool cover -html=./coverage/unit.cov -o ./coverage/unit.html
|
|
||||||
|
|
||||||
rm -f ./test/docker/coverage/*.cov
|
|
||||||
rm -f ./coverage/docker.*
|
|
||||||
mkdir -p ./test/docker/coverage/
|
|
||||||
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER)-cover TEST_COVER=true go test $(TEST_OPTS_DOCKER)
|
|
||||||
echo 'mode: count' > ./coverage/docker.cov
|
|
||||||
tail -q -n +2 ./test/docker/coverage/*.cov >> ./coverage/docker.cov
|
|
||||||
go tool cover -html=./coverage/docker.cov -o ./coverage/docker.html
|
|
||||||
|
|
||||||
echo 'mode: count' > ./coverage/combined.cov
|
|
||||||
tail -q -n +2 ./coverage/unit.cov ./coverage/docker.cov >> ./coverage/combined.cov
|
|
||||||
go tool cover -html=./coverage/combined.cov -o ./coverage/combined.html
|
|
||||||
|
|
||||||
define docker-build-mq
|
|
||||||
# Create a temporary network to use for the build
|
|
||||||
$(DOCKER) network create build
|
|
||||||
# Start a web server to host the MQ downloadable (tar.gz) file
|
|
||||||
$(DOCKER) run \
|
|
||||||
--rm \
|
|
||||||
--name $(BUILD_SERVER_CONTAINER) \
|
|
||||||
--network build \
|
|
||||||
--network-alias build \
|
|
||||||
--volume $(DOWNLOADS_DIR):/usr/share/nginx/html:ro \
|
|
||||||
--detach \
|
|
||||||
nginx:alpine
|
|
||||||
# Build the new image
|
|
||||||
$(DOCKER) build \
|
|
||||||
--tag $1 \
|
|
||||||
--file $2 \
|
|
||||||
--network build \
|
|
||||||
--build-arg MQ_URL=http://build:80/$3 \
|
|
||||||
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
|
|
||||||
--build-arg BUILDER_IMAGE=$(MQ_IMAGE_GOLANG_SDK) \
|
|
||||||
--build-arg IMAGE_REVISION="$(IMAGE_REVISION)" \
|
|
||||||
--build-arg IMAGE_CREATED="$(IMAGE_CREATED)" \
|
|
||||||
--build-arg IMAGE_SOURCE="$(IMAGE_SOURCE)" \
|
|
||||||
--label IBM_PRODUCT_ID=$4 \
|
|
||||||
--label IBM_PRODUCT_NAME=$5 \
|
|
||||||
--label IBM_PRODUCT_VERSION=$6 \
|
|
||||||
--build-arg MQ_PACKAGES="$(MQ_PACKAGES)" \
|
|
||||||
. ; $(DOCKER) kill $(BUILD_SERVER_CONTAINER) && $(DOCKER) network rm build
|
|
||||||
endef
|
|
||||||
|
|
||||||
DOCKER_SERVER_VERSION=$(shell docker version --format "{{ .Server.Version }}")
|
|
||||||
DOCKER_CLIENT_VERSION=$(shell docker version --format "{{ .Client.Version }}")
|
|
||||||
.PHONY: docker-version
|
|
||||||
docker-version:
|
|
||||||
@test "$(word 1,$(subst ., ,$(DOCKER_CLIENT_VERSION)))" -ge "17" || ("$(word 1,$(subst ., ,$(DOCKER_CLIENT_VERSION)))" -eq "17" && "$(word 2,$(subst ., ,$(DOCKER_CLIENT_VERSION)))" -ge "05") || (echo "Error: Docker client 17.05 or greater is required" && exit 1)
|
|
||||||
@test "$(word 1,$(subst ., ,$(DOCKER_SERVER_VERSION)))" -ge "17" || ("$(word 1,$(subst ., ,$(DOCKER_SERVER_VERSION)))" -eq "17" && "$(word 2,$(subst ., ,$(DOCKER_CLIENT_VERSION)))" -ge "05") || (echo "Error: Docker server 17.05 or greater is required" && exit 1)
|
|
||||||
|
|
||||||
.PHONY: build-advancedserver
|
|
||||||
build-advancedserver: MQ_SDK_ARCHIVE=$(MQ_ARCHIVE)
|
|
||||||
build-advancedserver: downloads/$(MQ_ARCHIVE) docker-version build-golang-sdk-ex
|
|
||||||
$(info $(SPACER)$(shell printf $(TITLE)"Build $(MQ_IMAGE_ADVANCEDSERVER)"$(END)))
|
|
||||||
$(call docker-build-mq,$(MQ_IMAGE_ADVANCEDSERVER),Dockerfile-server,$(MQ_ARCHIVE),"4486e8c4cc9146fd9b3ce1f14a2dfc5b","IBM MQ Advanced",$(MQ_VERSION))
|
|
||||||
|
|
||||||
.PHONY: build-devserver
|
|
||||||
# Target-specific variable to add web server into devserver image
|
|
||||||
ifeq "$(findstring ubuntu,$(BASE_IMAGE))" "ubuntu"
|
|
||||||
build-devserver: MQ_PACKAGES=ibmmq-server ibmmq-java ibmmq-jre ibmmq-gskit ibmmq-msg-.* ibmmq-samples ibmmq-ams ibmmq-web
|
|
||||||
else
|
|
||||||
build-devserver: MQ_PACKAGES=MQSeriesRuntime-*.rpm MQSeriesServer-*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesMsg*.rpm MQSeriesSamples*.rpm MQSeriesAMS-*.rpm MQSeriesWeb-*.rpm
|
|
||||||
endif
|
|
||||||
build-devserver: MQ_SDK_ARCHIVE=$(MQ_ARCHIVE_DEV)
|
|
||||||
build-devserver: downloads/$(MQ_ARCHIVE_DEV) docker-version build-golang-sdk-ex
|
|
||||||
$(info $(shell printf $(TITLE)"Build $(MQ_IMAGE_DEVSERVER_BASE)"$(END)))
|
|
||||||
$(call docker-build-mq,$(MQ_IMAGE_DEVSERVER_BASE),Dockerfile-server,$(MQ_ARCHIVE_DEV),"98102d16795c4263ad9ca075190a2d4d","IBM MQ Advanced for Developers (Non-Warranted)",$(MQ_VERSION))
|
|
||||||
$(DOCKER) build --tag $(MQ_IMAGE_DEVSERVER) --build-arg IMAGE_SOURCE="$(IMAGE_SOURCE)" --build-arg IMAGE_REVISION="$(IMAGE_REVISION)" --build-arg IMAGE_CREATED="$(IMAGE_CREATED)" --build-arg BASE_IMAGE=$(MQ_IMAGE_DEVSERVER_BASE) --build-arg BUILDER_IMAGE=$(MQ_IMAGE_GOLANG_SDK) --file incubating/mqadvanced-server-dev/Dockerfile .
|
|
||||||
|
|
||||||
.PHONY: build-advancedserver-cover
|
|
||||||
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)
|
|
||||||
$(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
|
|
||||||
build-sdk: downloads/$(MQ_SDK_ARCHIVE) build-sdk-ex
|
|
||||||
|
|
||||||
.PHONY: build-sdk-ex
|
|
||||||
ifeq "$(findstring ubuntu,$(BASE_IMAGE))" "ubuntu"
|
|
||||||
build-sdk-ex: MQ_PACKAGES=ibmmq-sdk ibmmq-samples build-essential
|
|
||||||
else
|
|
||||||
build-sdk-ex: MQ_PACKAGES=MQSeriesRuntime-*.rpm MQSeriesSDK-*.rpm MQSeriesSamples*.rpm
|
|
||||||
endif
|
|
||||||
build-sdk-ex: docker-version docker-pull
|
|
||||||
$(call docker-build-mq,$(MQ_IMAGE_SDK),incubating/mq-sdk/Dockerfile,$(MQ_SDK_ARCHIVE),"98102d16795c4263ad9ca075190a2d4d","IBM MQ Advanced for Developers SDK (Non-Warranted)",$(MQ_VERSION))
|
|
||||||
|
|
||||||
.PHONY: build-golang-sdk
|
|
||||||
build-golang-sdk: downloads/$(MQ_SDK_ARCHIVE) build-golang-sdk-ex
|
|
||||||
|
|
||||||
.PHONY: build-golang-sdk-ex
|
|
||||||
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))
|
|
||||||
|
|
||||||
docker-pull:
|
|
||||||
$(DOCKER) pull $(BASE_IMAGE)
|
|
||||||
|
|
||||||
GO_PKG_DIRS = ./cmd ./internal ./test
|
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
fmt: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS))
|
fmt: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS))
|
||||||
go fmt $(addsuffix /..., $(GO_PKG_DIRS))
|
go fmt $(addsuffix /..., $(GO_PKG_DIRS))
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
lint: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS))
|
lint: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS))
|
||||||
@# This expression is necessary because /... includes the vendor directory in golint
|
@# 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
|
@# 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)))))
|
golint -set_exit_status $(sort $(dir $(wildcard $(addsuffix /*/*.go, $(GO_PKG_DIRS)))))
|
||||||
|
|
||||||
|
.PHONY: gosec
|
||||||
|
gosec: $(info $(SPACER)$(shell printf "Running gosec test"$(END)))
|
||||||
|
@gosec -fmt=json -out=gosec_results.json cmd/... internal/... 2> /dev/null ;\
|
||||||
|
cat "gosec_results.json" ;\
|
||||||
|
cat gosec_results.json | grep HIGH | grep severity > /dev/null ;\
|
||||||
|
if [ $$? -eq 0 ]; then \
|
||||||
|
printf "\nFAILURE: gosec found files containing HIGH severity issues - see results.json\n" ;\
|
||||||
|
exit 1 ;\
|
||||||
|
else \
|
||||||
|
printf "\ngosec found no HIGH severity issues\n" ;\
|
||||||
|
fi ;\
|
||||||
|
cat gosec_results.json | grep MEDIUM | grep severity > /dev/null ;\
|
||||||
|
if [ $$? -eq 0 ]; then \
|
||||||
|
printf "\nFAILURE: gosec found files containing MEDIUM severity issues - see results.json\n" ;\
|
||||||
|
exit 1 ;\
|
||||||
|
else \
|
||||||
|
printf "\ngosec found no MEDIUM severity issues\n" ;\
|
||||||
|
fi ;\
|
||||||
|
cat gosec_results.json | grep LOW | grep severity > /dev/null;\
|
||||||
|
if [ $$? -eq 0 ]; then \
|
||||||
|
printf "\nFAILURE: gosec found files containing LOW severity issues - see results.json\n" ;\
|
||||||
|
exit 1;\
|
||||||
|
else \
|
||||||
|
printf "\ngosec found no LOW severity issues\n" ;\
|
||||||
|
fi ;\
|
||||||
|
|
||||||
|
.PHONY: unknownos
|
||||||
|
unknownos:
|
||||||
|
$(info $(SPACER)$(shell printf "ERROR: Unknown OS ("$(BASE_OS)") please run specific make targets"$(END)))
|
||||||
|
exit 1
|
||||||
|
|
||||||
include formatting.mk
|
include formatting.mk
|
||||||
|
|||||||
197
Makefile-RHEL
Normal file
197
Makefile-RHEL
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
# © 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.
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Conditional variables - you can override the values of these variables from
|
||||||
|
# the command line
|
||||||
|
###############################################################################
|
||||||
|
# BASE_IMAGE is the base image to use for MQ, for example "ubuntu" or "rhel"
|
||||||
|
BASE_IMAGE ?= rhel
|
||||||
|
# MQ_VERSION is the fully qualified MQ version number to build
|
||||||
|
MQ_VERSION ?= 9.1.1.0
|
||||||
|
# MQ_ARCHIVE is the name of the file, under the downloads directory, from which MQ Advanced can
|
||||||
|
# be installed. The default value is derived from MQ_VERSION, BASE_IMAGE and architecture
|
||||||
|
# Does not apply to MQ Advanced for Developers.
|
||||||
|
MQ_ARCHIVE ?= IBM_MQ_$(MQ_VERSION)_LINUX_$(MQ_ARCHIVE_ARCH).tar.gz
|
||||||
|
# MQ_ARCHIVE_DEV is the name of the file, under the downloads directory, from which MQ Advanced
|
||||||
|
# for Developers can be installed
|
||||||
|
MQ_ARCHIVE_DEV ?= $(MQ_ARCHIVE_DEV_$(MQ_VERSION))
|
||||||
|
# MQ_SDK_ARCHIVE specifies the archive to use for building the golang programs. Defaults vary on developer or advanced.
|
||||||
|
MQ_SDK_ARCHIVE ?= $(MQ_ARCHIVE_DEV_$(MQ_VERSION))
|
||||||
|
# Options to `go test` for the Docker tests
|
||||||
|
TEST_OPTS_DOCKER ?=
|
||||||
|
# MQ_IMAGE_ADVANCEDSERVER is the name and tag of the built MQ Advanced image
|
||||||
|
MQ_IMAGE_ADVANCEDSERVER ?=mqadvanced-server:$(MQ_VERSION)-RHEL-$(ARCH)
|
||||||
|
# MQ_IMAGE_DEVSERVER is the name and tag of the built MQ Advanced for Developers image
|
||||||
|
MQ_IMAGE_DEVSERVER ?=mqadvanced-server-dev:$(MQ_VERSION)-RHEL-$(ARCH)
|
||||||
|
# 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)
|
||||||
|
# MQ_PACKAGES specifies the MQ packages to install. Defaults vary on base image.
|
||||||
|
MQ_PACKAGES ?= MQSeriesRuntime-*.rpm MQSeriesServer-*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesMsg*.rpm MQSeriesSamples*.rpm MQSeriesAMS-*.rpm
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Other variables
|
||||||
|
###############################################################################
|
||||||
|
# ARCH is the platform architecture (e.g. x86_64, ppc64le or s390x)
|
||||||
|
ARCH = $(shell uname -m)
|
||||||
|
# BASE_IMAGE_TAG is a normalized version of BASE_IMAGE, suitable for use in a Docker tag
|
||||||
|
BASE_IMAGE_TAG=$(subst /,-,$(subst :,-,$(BASE_IMAGE)))
|
||||||
|
MQ_IMAGE_DEVSERVER_BASE=mqadvanced-server-dev-base:$(MQ_VERSION)-$(ARCH)-$(BASE_IMAGE_TAG)
|
||||||
|
# Docker image name to use for JMS tests
|
||||||
|
DEV_JMS_IMAGE=mq-dev-jms-test:latest
|
||||||
|
# Variables for versioning
|
||||||
|
IMAGE_REVISION=$(shell git rev-parse HEAD)
|
||||||
|
IMAGE_SOURCE=$(shell git config --get remote.origin.url)
|
||||||
|
MQDEV=
|
||||||
|
|
||||||
|
|
||||||
|
ifneq (,$(findstring Microsoft,$(shell uname -r)))
|
||||||
|
DOWNLOADS_DIR=$(patsubst /mnt/c%,C:%,$(realpath ./downloads/))
|
||||||
|
else
|
||||||
|
DOWNLOADS_DIR=$(realpath ./downloads/)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Try to figure out which archive to use from the architecture
|
||||||
|
ifeq "$(ARCH)" "x86_64"
|
||||||
|
MQ_ARCHIVE_ARCH=X86-64
|
||||||
|
MQ_DEV_ARCH=x86-64
|
||||||
|
else ifeq "$(ARCH)" "ppc64le"
|
||||||
|
MQ_ARCHIVE_ARCH=LE_POWER
|
||||||
|
MQ_DEV_ARCH=ppcle
|
||||||
|
else ifeq "$(ARCH)" "s390x"
|
||||||
|
MQ_ARCHIVE_ARCH=SYSTEM_Z
|
||||||
|
MQ_DEV_ARCH=s390x
|
||||||
|
endif
|
||||||
|
# Archive names for IBM MQ Advanced for Developers
|
||||||
|
MQ_ARCHIVE_DEV_9.0.5.0=mqadv_dev905_linux_x86-64.tar.gz
|
||||||
|
MQ_ARCHIVE_DEV_9.1.0.0=mqadv_dev910_linux_$(MQ_DEV_ARCH).tar.gz
|
||||||
|
MQ_ARCHIVE_DEV_9.1.1.0=mqadv_dev910_linux_$(MQ_DEV_ARCH).tar.gz
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Build targets
|
||||||
|
###############################################################################
|
||||||
|
.PHONY: vars
|
||||||
|
vars:
|
||||||
|
#ifeq "$(findstring ubuntu,$(BASE_IMAGE))","ubuntu"
|
||||||
|
@echo $(MQ_ARCHIVE_ARCH)
|
||||||
|
@echo $(MQ_ARCHIVE_TYPE)
|
||||||
|
@echo $(MQ_ARCHIVE)
|
||||||
|
|
||||||
|
.PHONY: default
|
||||||
|
default: build-devserver test-devserver
|
||||||
|
|
||||||
|
# Build all components (except incubating ones)
|
||||||
|
.PHONY: all
|
||||||
|
all: build-devserver build-advancedserver
|
||||||
|
|
||||||
|
.PHONY: test-all
|
||||||
|
test-all: build-devjmstest test-devserver test-advancedserver
|
||||||
|
|
||||||
|
.PHONY: devserver
|
||||||
|
devserver: build-devserver build-devjmstest test-devserver
|
||||||
|
|
||||||
|
# Build incubating components
|
||||||
|
.PHONY: incubating
|
||||||
|
incubating: build-explorer
|
||||||
|
|
||||||
|
downloads/$(MQ_ARCHIVE_DEV):
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Downloading IBM MQ Advanced for Developers "$(MQ_VERSION)$(END)))
|
||||||
|
mkdir -p downloads
|
||||||
|
cd downloads; curl -LO https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/$(MQ_ARCHIVE_DEV)
|
||||||
|
|
||||||
|
downloads/$(MQ_SDK_ARCHIVE):
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Downloading IBM MQ Advanced for Developers "$(MQ_VERSION)$(END)))
|
||||||
|
mkdir -p downloads
|
||||||
|
cd downloads; curl -LO https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/$(MQ_SDK_ARCHIVE)
|
||||||
|
|
||||||
|
.PHONY: downloads
|
||||||
|
downloads: downloads/$(MQ_ARCHIVE_DEV) downloads/$(MQ_SDK_ARCHIVE)
|
||||||
|
|
||||||
|
# Vendor Go dependencies for the Docker tests
|
||||||
|
test/docker/vendor:
|
||||||
|
cd test/docker && dep ensure -vendor-only
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: check-prereqs
|
||||||
|
check-prereqs:
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Checking for prereqs"$(END)))
|
||||||
|
which buildah || (echo "Missing required program buildah" && exit 1)
|
||||||
|
which podman || (echo "Missing required program podman" && exit 1)
|
||||||
|
yum list | grep yum-utils || (echo "Missing required package yum-utils" && exit 1)
|
||||||
|
|
||||||
|
.PHONY: check-test-prereqs
|
||||||
|
check-prereqs:
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Checking for prereqs"$(END)))
|
||||||
|
which buildah || (echo "Missing required program buildah" && exit 1)
|
||||||
|
which docker || (echo "Missing required program docker" && exit 1)
|
||||||
|
|
||||||
|
.PHONY: test-advancedserver
|
||||||
|
test-advancedserver: check-test-prereqs test/docker/vendor
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_ADVANCEDSERVER) on $(shell docker --version)"$(END)))
|
||||||
|
sudo buildah push $(MQ_IMAGE_ADVANCEDSERVER) docker-daemon:$(MQ_IMAGE_ADVANCEDSERVER)
|
||||||
|
docker tag docker.io/$(MQ_IMAGE_ADVANCEDSERVER) $(MQ_IMAGE_ADVANCEDSERVER)
|
||||||
|
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER) EXPECTED_LICENSE=Production go test $(TEST_OPTS_DOCKER)
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: test-devserver
|
||||||
|
test-devserver: check-test-prereqs test/docker/vendor
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_DEVSERVER) on $(shell docker --version)"$(END)))
|
||||||
|
sudo buildah push $(MQ_IMAGE_DEVSERVER) docker-daemon:$(MQ_IMAGE_DEVSERVER)
|
||||||
|
docker tag docker.io/$(MQ_IMAGE_DEVSERVER) $(MQ_IMAGE_DEVSERVER)
|
||||||
|
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_DEVSERVER) EXPECTED_LICENSE=Developer DEV_JMS_IMAGE=$(DEV_JMS_IMAGE) go test -tags mqdev $(TEST_OPTS_DOCKER)
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: build-advancedserver
|
||||||
|
build-advancedserver: MQ_SDK_ARCHIVE=$(MQ_ARCHIVE)
|
||||||
|
build-advancedserver: check-prereqs downloads/$(MQ_ARCHIVE) build-go-programs-ex
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Build $(MQ_IMAGE_ADVANCEDSERVER)"$(END)))
|
||||||
|
sudo mq-advanced-server-rhel/mq-buildah.sh "$(MQ_ARCHIVE)" "$(MQ_PACKAGES)" "$(MQ_IMAGE_ADVANCEDSERVER)" "$(MQ_VERSION)" "$(MQDEV)"
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: build-devserver
|
||||||
|
build-devserver: MQ_SDK_ARCHIVE=$(MQ_ARCHIVE_DEV)
|
||||||
|
build-devserver: MQDEV=TRUE
|
||||||
|
build-devserver: MQ_PACKAGES=MQSeriesRuntime-*.rpm MQSeriesServer-*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesMsg*.rpm MQSeriesSamples*.rpm MQSeriesAMS-*.rpm MQSeriesWeb-*.rpm
|
||||||
|
build-devserver: check-prereqs downloads/$(MQ_ARCHIVE_DEV) build-go-programs-ex
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Build $(MQ_IMAGE_DEVSERVER)"$(END)))
|
||||||
|
sudo mq-advanced-server-rhel/mq-buildah.sh "$(MQ_ARCHIVE_DEV)" "$(MQ_PACKAGES)" "$(MQ_IMAGE_DEVSERVER_BASE)" "$(MQ_VERSION)" "$(MQDEV)"
|
||||||
|
sudo mq-advanced-server-rhel/mqdev-buildah.sh "$(MQ_IMAGE_DEVSERVER_BASE)" "$(MQ_IMAGE_DEVSERVER)" "$(MQ_VERSION)"
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: build-mqgolang-sdk
|
||||||
|
build-mqgolang-sdk: check-prereqs downloads/$(MQ_SDK_ARCHIVE) build-mqgolang-sdk-ex
|
||||||
|
|
||||||
|
.PHONY: build-mqgolang-sdk-ex
|
||||||
|
build-mqgolang-sdk-ex:
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Build mq-golang SDK"$(END)))
|
||||||
|
sudo mq-advanced-server-rhel/mq-golang-sdk-buildah.sh "$(MQ_SDK_ARCHIVE)" "$(MQ_IMAGE_GOLANG_SDK)"
|
||||||
|
|
||||||
|
.PHONY: build-go-programs
|
||||||
|
build-go-programs: check-prereqs downloads/$(MQ_SDK_ARCHIVE) build-go-programs-ex
|
||||||
|
|
||||||
|
.PHONY: build-go-programs-ex
|
||||||
|
build-go-programs-ex: build-mqgolang-sdk-ex
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Build go programs"$(END)))
|
||||||
|
IMAGE_REVISION=$(IMAGE_REVISION) IMAGE_SOURCE=$(IMAGE_SOURCE) sudo mq-advanced-server-rhel/go-buildah.sh "$(MQ_IMAGE_GOLANG_SDK)" "$(MQDEV)"
|
||||||
|
|
||||||
|
.PHONY: build-devjmstest
|
||||||
|
build-devjmstest: check-test-prereqs
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Build JMS tests for developer config"$(END)))
|
||||||
|
cd test/messaging && sudo ./buildah.sh $(DEV_JMS_IMAGE)
|
||||||
|
sudo buildah push $(DEV_JMS_IMAGE) docker-daemon:$(DEV_JMS_IMAGE)
|
||||||
|
docker tag docker.io/$(DEV_JMS_IMAGE) $(DEV_JMS_IMAGE)
|
||||||
|
|
||||||
|
include formatting.mk
|
||||||
273
Makefile-UBUNTU
Normal file
273
Makefile-UBUNTU
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
# © Copyright IBM Corporation 2017, 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.
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Conditional variables - you can override the values of these variables from
|
||||||
|
# the command line
|
||||||
|
###############################################################################
|
||||||
|
# BASE_IMAGE is the base image to use for MQ, for example "ubuntu" or "rhel"
|
||||||
|
BASE_IMAGE ?= ubuntu:16.04
|
||||||
|
# MQ_VERSION is the fully qualified MQ version number to build
|
||||||
|
MQ_VERSION ?= 9.1.1.0
|
||||||
|
# MQ_ARCHIVE is the name of the file, under the downloads directory, from which MQ Advanced can
|
||||||
|
# be installed. The default value is derived from MQ_VERSION, BASE_IMAGE and architecture
|
||||||
|
# Does not apply to MQ Advanced for Developers.
|
||||||
|
MQ_ARCHIVE ?= IBM_MQ_$(MQ_VERSION)_$(MQ_ARCHIVE_TYPE)_$(MQ_ARCHIVE_ARCH).tar.gz
|
||||||
|
# MQ_ARCHIVE_DEV is the name of the file, under the downloads directory, from which MQ Advanced
|
||||||
|
# for Developers can be installed
|
||||||
|
MQ_ARCHIVE_DEV ?= $(MQ_ARCHIVE_DEV_$(MQ_VERSION))
|
||||||
|
# MQ_SDK_ARCHIVE specifies the archive to use for building the golang programs. Defaults vary on developer or advanced.
|
||||||
|
MQ_SDK_ARCHIVE ?= $(MQ_ARCHIVE_DEV_$(MQ_VERSION))
|
||||||
|
# Options to `go test` for the Docker tests
|
||||||
|
TEST_OPTS_DOCKER ?=
|
||||||
|
# MQ_IMAGE_ADVANCEDSERVER is the name and tag of the built MQ Advanced image
|
||||||
|
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.
|
||||||
|
MQ_PACKAGES ?=
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Other variables
|
||||||
|
###############################################################################
|
||||||
|
# ARCH is the platform architecture (e.g. x86_64, ppc64le or s390x)
|
||||||
|
ARCH = $(shell uname -m)
|
||||||
|
# BUILD_SERVER_CONTAINER is the name of the web server container used at build time
|
||||||
|
BUILD_SERVER_CONTAINER=build-server
|
||||||
|
# NUM_CPU is the number of CPUs available to Docker. Used to control how many
|
||||||
|
# test run in parallel
|
||||||
|
NUM_CPU = $(or $(shell docker info --format "{{ .NCPU }}"),2)
|
||||||
|
# BASE_IMAGE_TAG is a normalized version of BASE_IMAGE, suitable for use in a Docker tag
|
||||||
|
BASE_IMAGE_TAG=$(subst /,-,$(subst :,-,$(BASE_IMAGE)))
|
||||||
|
MQ_IMAGE_DEVSERVER_BASE=mqadvanced-server-dev-base:$(MQ_VERSION)-$(ARCH)-$(BASE_IMAGE_TAG)
|
||||||
|
# Docker image name to use for JMS tests
|
||||||
|
DEV_JMS_IMAGE=mq-dev-jms-test
|
||||||
|
# Variables for versioning
|
||||||
|
IMAGE_REVISION=$(shell git rev-parse HEAD)
|
||||||
|
IMAGE_SOURCE=$(shell git config --get remote.origin.url)
|
||||||
|
|
||||||
|
ifneq (,$(findstring Microsoft,$(shell uname -r)))
|
||||||
|
DOWNLOADS_DIR=$(patsubst /mnt/c%,C:%,$(realpath ./downloads/))
|
||||||
|
else
|
||||||
|
DOWNLOADS_DIR=$(realpath ./downloads/)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Try to figure out which archive to use from the BASE_IMAGE
|
||||||
|
ifeq "$(findstring ubuntu,$(BASE_IMAGE))" "ubuntu"
|
||||||
|
MQ_ARCHIVE_TYPE=UBUNTU
|
||||||
|
MQ_ARCHIVE_DEV_PLATFORM=ubuntu
|
||||||
|
else
|
||||||
|
MQ_ARCHIVE_TYPE=LINUX
|
||||||
|
MQ_ARCHIVE_DEV_PLATFORM=linux
|
||||||
|
endif
|
||||||
|
# Try to figure out which archive to use from the architecture
|
||||||
|
ifeq "$(ARCH)" "x86_64"
|
||||||
|
MQ_ARCHIVE_ARCH=X86-64
|
||||||
|
MQ_DEV_ARCH=x86-64
|
||||||
|
else ifeq "$(ARCH)" "ppc64le"
|
||||||
|
MQ_ARCHIVE_ARCH=LE_POWER
|
||||||
|
MQ_DEV_ARCH=ppcle
|
||||||
|
else ifeq "$(ARCH)" "s390x"
|
||||||
|
MQ_ARCHIVE_ARCH=SYSTEM_Z
|
||||||
|
MQ_DEV_ARCH=s390x
|
||||||
|
endif
|
||||||
|
# Archive names for IBM MQ Advanced for Developers
|
||||||
|
MQ_ARCHIVE_DEV_9.0.5.0=mqadv_dev905_$(MQ_ARCHIVE_DEV_PLATFORM)_x86-64.tar.gz
|
||||||
|
MQ_ARCHIVE_DEV_9.1.0.0=mqadv_dev910_$(MQ_ARCHIVE_DEV_PLATFORM)_$(MQ_DEV_ARCH).tar.gz
|
||||||
|
MQ_ARCHIVE_DEV_9.1.1.0=mqadv_dev911_$(MQ_ARCHIVE_DEV_PLATFORM)_$(MQ_DEV_ARCH).tar.gz
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Build targets
|
||||||
|
###############################################################################
|
||||||
|
.PHONY: vars
|
||||||
|
vars:
|
||||||
|
#ifeq "$(findstring ubuntu,$(BASE_IMAGE))","ubuntu"
|
||||||
|
@echo $(MQ_ARCHIVE_ARCH)
|
||||||
|
@echo $(MQ_ARCHIVE_TYPE)
|
||||||
|
@echo $(MQ_ARCHIVE)
|
||||||
|
|
||||||
|
.PHONY: default
|
||||||
|
default: build-devserver test
|
||||||
|
|
||||||
|
# Build all components (except incubating ones)
|
||||||
|
.PHONY: all
|
||||||
|
all: build-devserver build-advancedserver
|
||||||
|
|
||||||
|
.PHONY: test-all
|
||||||
|
test-all: build-devjmstest test-devserver test-advancedserver
|
||||||
|
|
||||||
|
.PHONY: devserver
|
||||||
|
devserver: build-devserver build-devjmstest test-devserver
|
||||||
|
|
||||||
|
# Build incubating components
|
||||||
|
.PHONY: incubating
|
||||||
|
incubating: build-explorer
|
||||||
|
|
||||||
|
downloads/$(MQ_ARCHIVE_DEV):
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Downloading IBM MQ Advanced for Developers "$(MQ_VERSION)$(END)))
|
||||||
|
mkdir -p downloads
|
||||||
|
cd downloads; curl -LO https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/$(MQ_ARCHIVE_DEV)
|
||||||
|
|
||||||
|
downloads/$(MQ_SDK_ARCHIVE):
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Downloading IBM MQ Advanced for Developers "$(MQ_VERSION)$(END)))
|
||||||
|
mkdir -p downloads
|
||||||
|
cd downloads; curl -LO https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/$(MQ_SDK_ARCHIVE)
|
||||||
|
|
||||||
|
.PHONY: downloads
|
||||||
|
downloads: downloads/$(MQ_ARCHIVE_DEV) downloads/$(MQ_SDK_ARCHIVE)
|
||||||
|
|
||||||
|
# Vendor Go dependencies for the Docker tests
|
||||||
|
test/docker/vendor:
|
||||||
|
cd test/docker && dep ensure -vendor-only
|
||||||
|
|
||||||
|
# Shortcut to just run the unit tests
|
||||||
|
.PHONY: test-unit
|
||||||
|
test-unit:
|
||||||
|
docker build --target builder --file Dockerfile-server .
|
||||||
|
|
||||||
|
.PHONY: test-advancedserver
|
||||||
|
test-advancedserver: test/docker/vendor
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_ADVANCEDSERVER) on $(shell docker --version)"$(END)))
|
||||||
|
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER) EXPECTED_LICENSE=Production go test -parallel $(NUM_CPU) $(TEST_OPTS_DOCKER)
|
||||||
|
|
||||||
|
.PHONY: build-devjmstest
|
||||||
|
build-devjmstest:
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Build JMS tests for developer config"$(END)))
|
||||||
|
cd test/messaging && docker build --tag $(DEV_JMS_IMAGE) .
|
||||||
|
|
||||||
|
.PHONY: test-devserver
|
||||||
|
test-devserver: test/docker/vendor
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_DEVSERVER) on $(shell docker --version)"$(END)))
|
||||||
|
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_DEVSERVER) EXPECTED_LICENSE=Developer DEV_JMS_IMAGE=$(DEV_JMS_IMAGE) IBMJRE=true go test -parallel $(NUM_CPU) -tags mqdev $(TEST_OPTS_DOCKER)
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
mkdir coverage
|
||||||
|
|
||||||
|
.PHONY: test-advancedserver-cover
|
||||||
|
test-advancedserver-cover: test/docker/vendor coverage
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_ADVANCEDSERVER) with code coverage on $(shell docker --version)"$(END)))
|
||||||
|
rm -f ./coverage/unit*.cov
|
||||||
|
# Run unit tests with coverage, for each package under 'internal'
|
||||||
|
go list -f '{{.Name}}' ./internal/... | xargs -I {} go test -cover -covermode count -coverprofile ./coverage/unit-{}.cov ./internal/{}
|
||||||
|
# ls -1 ./cmd | xargs -I {} go test -cover -covermode count -coverprofile ./coverage/unit-{}.cov ./cmd/{}/...
|
||||||
|
echo 'mode: count' > ./coverage/unit.cov
|
||||||
|
tail -q -n +2 ./coverage/unit-*.cov >> ./coverage/unit.cov
|
||||||
|
go tool cover -html=./coverage/unit.cov -o ./coverage/unit.html
|
||||||
|
|
||||||
|
rm -f ./test/docker/coverage/*.cov
|
||||||
|
rm -f ./coverage/docker.*
|
||||||
|
mkdir -p ./test/docker/coverage/
|
||||||
|
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER)-cover TEST_COVER=true go test $(TEST_OPTS_DOCKER)
|
||||||
|
echo 'mode: count' > ./coverage/docker.cov
|
||||||
|
tail -q -n +2 ./test/docker/coverage/*.cov >> ./coverage/docker.cov
|
||||||
|
go tool cover -html=./coverage/docker.cov -o ./coverage/docker.html
|
||||||
|
|
||||||
|
echo 'mode: count' > ./coverage/combined.cov
|
||||||
|
tail -q -n +2 ./coverage/unit.cov ./coverage/docker.cov >> ./coverage/combined.cov
|
||||||
|
go tool cover -html=./coverage/combined.cov -o ./coverage/combined.html
|
||||||
|
|
||||||
|
define docker-build-mq
|
||||||
|
# Create a temporary network to use for the build
|
||||||
|
$(DOCKER) network create build
|
||||||
|
# Start a web server to host the MQ downloadable (tar.gz) file
|
||||||
|
$(DOCKER) run \
|
||||||
|
--rm \
|
||||||
|
--name $(BUILD_SERVER_CONTAINER) \
|
||||||
|
--network build \
|
||||||
|
--network-alias build \
|
||||||
|
--volume $(DOWNLOADS_DIR):/usr/share/nginx/html:ro \
|
||||||
|
--detach \
|
||||||
|
nginx:alpine
|
||||||
|
# Build the new image
|
||||||
|
$(DOCKER) build \
|
||||||
|
--tag $1 \
|
||||||
|
--file $2 \
|
||||||
|
--network build \
|
||||||
|
--build-arg MQ_URL=http://build:80/$3 \
|
||||||
|
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
|
||||||
|
--build-arg BUILDER_IMAGE=$(MQ_IMAGE_GOLANG_SDK) \
|
||||||
|
--build-arg IMAGE_REVISION="$(IMAGE_REVISION)" \
|
||||||
|
--build-arg IMAGE_SOURCE="$(IMAGE_SOURCE)" \
|
||||||
|
--label IBM_PRODUCT_ID=$4 \
|
||||||
|
--label IBM_PRODUCT_NAME=$5 \
|
||||||
|
--label IBM_PRODUCT_VERSION=$6 \
|
||||||
|
--build-arg MQ_PACKAGES="$(MQ_PACKAGES)" \
|
||||||
|
. ; $(DOCKER) kill $(BUILD_SERVER_CONTAINER) && $(DOCKER) network rm build
|
||||||
|
endef
|
||||||
|
|
||||||
|
DOCKER_SERVER_VERSION=$(shell docker version --format "{{ .Server.Version }}")
|
||||||
|
DOCKER_CLIENT_VERSION=$(shell docker version --format "{{ .Client.Version }}")
|
||||||
|
.PHONY: docker-version
|
||||||
|
docker-version:
|
||||||
|
@test "$(word 1,$(subst ., ,$(DOCKER_CLIENT_VERSION)))" -ge "17" || ("$(word 1,$(subst ., ,$(DOCKER_CLIENT_VERSION)))" -eq "17" && "$(word 2,$(subst ., ,$(DOCKER_CLIENT_VERSION)))" -ge "05") || (echo "Error: Docker client 17.05 or greater is required" && exit 1)
|
||||||
|
@test "$(word 1,$(subst ., ,$(DOCKER_SERVER_VERSION)))" -ge "17" || ("$(word 1,$(subst ., ,$(DOCKER_SERVER_VERSION)))" -eq "17" && "$(word 2,$(subst ., ,$(DOCKER_CLIENT_VERSION)))" -ge "05") || (echo "Error: Docker server 17.05 or greater is required" && exit 1)
|
||||||
|
|
||||||
|
.PHONY: build-advancedserver
|
||||||
|
build-advancedserver: MQ_SDK_ARCHIVE=$(MQ_ARCHIVE)
|
||||||
|
build-advancedserver: downloads/$(MQ_ARCHIVE) docker-version build-golang-sdk-ex
|
||||||
|
$(info $(SPACER)$(shell printf $(TITLE)"Build $(MQ_IMAGE_ADVANCEDSERVER)"$(END)))
|
||||||
|
$(call docker-build-mq,$(MQ_IMAGE_ADVANCEDSERVER),Dockerfile-server,$(MQ_ARCHIVE),"4486e8c4cc9146fd9b3ce1f14a2dfc5b","IBM MQ Advanced",$(MQ_VERSION))
|
||||||
|
|
||||||
|
.PHONY: build-devserver
|
||||||
|
# Target-specific variable to add web server into devserver image
|
||||||
|
ifeq "$(findstring ubuntu,$(BASE_IMAGE))" "ubuntu"
|
||||||
|
build-devserver: MQ_PACKAGES=ibmmq-server ibmmq-java ibmmq-jre ibmmq-gskit ibmmq-msg-.* ibmmq-samples ibmmq-ams ibmmq-web
|
||||||
|
else
|
||||||
|
build-devserver: MQ_PACKAGES=MQSeriesRuntime-*.rpm MQSeriesServer-*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesMsg*.rpm MQSeriesSamples*.rpm MQSeriesAMS-*.rpm MQSeriesWeb-*.rpm
|
||||||
|
endif
|
||||||
|
build-devserver: MQ_SDK_ARCHIVE=$(MQ_ARCHIVE_DEV)
|
||||||
|
build-devserver: downloads/$(MQ_ARCHIVE_DEV) docker-version build-golang-sdk-ex
|
||||||
|
$(info $(shell printf $(TITLE)"Build $(MQ_IMAGE_DEVSERVER_BASE)"$(END)))
|
||||||
|
$(call docker-build-mq,$(MQ_IMAGE_DEVSERVER_BASE),Dockerfile-server,$(MQ_ARCHIVE_DEV),"98102d16795c4263ad9ca075190a2d4d","IBM MQ Advanced for Developers (Non-Warranted)",$(MQ_VERSION))
|
||||||
|
$(DOCKER) build --tag $(MQ_IMAGE_DEVSERVER) --build-arg IMAGE_SOURCE="$(IMAGE_SOURCE)" --build-arg IMAGE_REVISION="$(IMAGE_REVISION)" --build-arg BASE_IMAGE=$(MQ_IMAGE_DEVSERVER_BASE) --build-arg BUILDER_IMAGE=$(MQ_IMAGE_GOLANG_SDK) --file incubating/mqadvanced-server-dev/Dockerfile .
|
||||||
|
|
||||||
|
.PHONY: build-advancedserver-cover
|
||||||
|
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
|
||||||
|
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
|
||||||
|
build-sdk: downloads/$(MQ_SDK_ARCHIVE) build-sdk-ex
|
||||||
|
|
||||||
|
.PHONY: build-sdk-ex
|
||||||
|
ifeq "$(findstring ubuntu,$(BASE_IMAGE))" "ubuntu"
|
||||||
|
build-sdk-ex: MQ_PACKAGES=ibmmq-sdk ibmmq-samples build-essential
|
||||||
|
else
|
||||||
|
build-sdk-ex: MQ_PACKAGES=MQSeriesRuntime-*.rpm MQSeriesSDK-*.rpm MQSeriesSamples*.rpm
|
||||||
|
endif
|
||||||
|
build-sdk-ex: docker-version docker-pull
|
||||||
|
$(call docker-build-mq,$(MQ_IMAGE_SDK),incubating/mq-sdk/Dockerfile,$(MQ_SDK_ARCHIVE),"98102d16795c4263ad9ca075190a2d4d","IBM MQ Advanced for Developers SDK (Non-Warranted)",$(MQ_VERSION))
|
||||||
|
|
||||||
|
.PHONY: build-golang-sdk
|
||||||
|
build-golang-sdk: downloads/$(MQ_SDK_ARCHIVE) build-golang-sdk-ex
|
||||||
|
|
||||||
|
.PHONY: build-golang-sdk-ex
|
||||||
|
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)
|
||||||
|
|
||||||
|
include formatting.mk
|
||||||
31
README.md
31
README.md
@@ -1,26 +1,29 @@
|
|||||||

|
# IBM MQ container
|
||||||
|
|
||||||
# Overview
|
[](https://travis-ci.org/ibm-messaging/mq-container)
|
||||||
|
|
||||||
|
**Note**: The `master` branch may be in an *unstable or even broken state* during development.
|
||||||
|
To get a stable version, please use the correct [branch](https://github.com/ibm-messaging/mq-container/branches) for your MQ version, instead of the `master` branch.
|
||||||
|
|
||||||
|
<img src="https://raw.githubusercontent.com/IBM/charts/master/logo/ibm-mq-icon.svg?sanitize=true" width="100" alt="IBM MQ logo" />
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
Run [IBM® MQ](http://www-03.ibm.com/software/products/en/ibm-mq) in a container.
|
Run [IBM® MQ](http://www-03.ibm.com/software/products/en/ibm-mq) in a container.
|
||||||
|
|
||||||
You can build an image containing either IBM MQ Advanced, or IBM MQ Advanced for Developers. The developer image includes a [default developer configuration](docs/developer-config.md), to make it easier to get started. There is also an [incubating](incubating) folder for additional images for other MQ components, which you might find useful.
|
You can build an image containing either IBM MQ Advanced, or IBM MQ Advanced for Developers. The developer image includes a [default developer configuration](docs/developer-config.md), to make it easier to get started. There is also an [incubating](incubating) folder for additional images for other MQ components, which you might find useful.
|
||||||
|
|
||||||
# Current status
|
## Build
|
||||||
|
|
||||||
MQ Advanced for Developers image [](https://travis-ci.org/ibm-messaging/mq-container)
|
|
||||||
|
|
||||||
# Build
|
|
||||||
|
|
||||||
After extracting the code from this repository, you can follow the [build documentation](docs/building.md) to build an image.
|
After extracting the code from this repository, you can follow the [build documentation](docs/building.md) to build an image.
|
||||||
|
|
||||||
# Usage
|
## Usage
|
||||||
|
|
||||||
See the [usage documentation](docs/usage.md) for details on how to run a container.
|
See the [usage documentation](docs/usage.md) for details on how to run a container.
|
||||||
|
|
||||||
Note that in order to use the image, it is necessary to accept the terms of the [IBM MQ license](#license).
|
Note that in order to use the image, it is necessary to accept the terms of the [IBM MQ license](#license).
|
||||||
|
|
||||||
## Environment variables supported by this image
|
### Environment variables supported by this image
|
||||||
|
|
||||||
- **LICENSE** - Set this to `accept` to agree to the MQ Advanced for Developers license. If you wish to see the license you can set this to `view`.
|
- **LICENSE** - Set this to `accept` to agree to the MQ Advanced for Developers license. If you wish to see the license you can set this to `view`.
|
||||||
- **LANG** - Set this to the language you would like the license to be printed in.
|
- **LANG** - Set this to the language you would like the license to be printed in.
|
||||||
@@ -30,25 +33,25 @@ Note that in order to use the image, it is necessary to accept the terms of the
|
|||||||
|
|
||||||
See the [default developer configuration docs](docs/developer-config.md) for the extra environment variables supported by the MQ Advanced for Developers image.
|
See the [default developer configuration docs](docs/developer-config.md) for the extra environment variables supported by the MQ Advanced for Developers image.
|
||||||
|
|
||||||
## Kubernetes
|
### Kubernetes
|
||||||
|
|
||||||
If you want to use IBM MQ in [Kubernetes](https://kubernetes.io), you can find an example [Helm](https://helm.sh/) chart here: [IBM charts](https://github.com/IBM/charts). This can be used to run the container on a cluster, such as [IBM Cloud Private](https://www.ibm.com/cloud-computing/products/ibm-cloud-private/) or the [IBM Cloud Kubernetes Service](https://www.ibm.com/cloud/container-service).
|
If you want to use IBM MQ in [Kubernetes](https://kubernetes.io), you can find an example [Helm](https://helm.sh/) chart here: [IBM charts](https://github.com/IBM/charts). This can be used to run the container on a cluster, such as [IBM Cloud Private](https://www.ibm.com/cloud-computing/products/ibm-cloud-private/) or the [IBM Cloud Kubernetes Service](https://www.ibm.com/cloud/container-service).
|
||||||
|
|
||||||
# Issues and contributions
|
## Issues and contributions
|
||||||
|
|
||||||
For issues relating specifically to the container image or Helm chart, please use the [GitHub issue tracker](https://github.com/ibm-messaging/mq-container/issues). If you do submit a Pull Request related to this Docker image, please indicate in the Pull Request that you accept and agree to be bound by the terms of the [IBM Contributor License Agreement](CLA.md).
|
For issues relating specifically to the container image or Helm chart, please use the [GitHub issue tracker](https://github.com/ibm-messaging/mq-container/issues). If you do submit a Pull Request related to this Docker image, please indicate in the Pull Request that you accept and agree to be bound by the terms of the [IBM Contributor License Agreement](CLA.md).
|
||||||
|
|
||||||
# License
|
## License
|
||||||
|
|
||||||
The Dockerfiles and associated code and scripts are licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
|
The Dockerfiles and associated code and scripts are licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
|
||||||
Licenses for the products installed within the images are as follows:
|
Licenses for the products installed within the images are as follows:
|
||||||
|
|
||||||
- [IBM MQ Advanced for Developers](http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?la_formnum=Z125-3301-14&li_formnum=L-APIG-AVCJ4S) (International License Agreement for Non-Warranted Programs). This license may be viewed from an image using the `LICENSE=view` environment variable as described above or by following the link above.
|
- [IBM MQ Advanced for Developers](http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?la_formnum=Z125-3301-14&li_formnum=L-APIG-AVCJ4S) (International License Agreement for Non-Warranted Programs). This license may be viewed from an image using the `LICENSE=view` environment variable as described above or by following the link above.
|
||||||
- [IBM MQ Advanced](http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?la_formnum=Z125-3301-14&li_formnum=L-APIG-AV6GV5) (International Program License Agreement). This license may be viewed from an image using the `LICENSE=view` environment variable as described above or by following the link above.
|
- [IBM MQ Advanced](http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?la_formnum=Z125-3301-14&li_formnum=L-APIG-AZYF4X) (International Program License Agreement). This license may be viewed from an image using the `LICENSE=view` environment variable as described above or by following the link above.
|
||||||
- License information for Ubuntu packages may be found in `/usr/share/doc/${package}/copyright`
|
- License information for Ubuntu packages may be found in `/usr/share/doc/${package}/copyright`
|
||||||
|
|
||||||
Note: The IBM MQ Advanced for Developers license does not permit further distribution and the terms restrict usage to a developer machine.
|
Note: The IBM MQ Advanced for Developers license does not permit further distribution and the terms restrict usage to a developer machine.
|
||||||
|
|
||||||
# Copyright
|
## Copyright
|
||||||
|
|
||||||
© Copyright IBM Corporation 2015, 2018
|
© Copyright IBM Corporation 2015, 2018
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ func queueManagerHealthy() (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
// Specify the queue manager name, just in case someone's created a second queue manager
|
// Specify the queue manager name, just in case someone's created a second queue manager
|
||||||
|
// #nosec G204
|
||||||
cmd := exec.Command("dspmq", "-n", "-m", name)
|
cmd := exec.Command("dspmq", "-n", "-m", name)
|
||||||
// Run the command and wait for completion
|
// Run the command and wait for completion
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
|
|||||||
@@ -37,5 +37,8 @@ func main() {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
conn.Close()
|
err = conn.Close()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,11 +65,27 @@ func (ks *KeyStore) Create() error {
|
|||||||
stashFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".sth"
|
stashFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".sth"
|
||||||
rdbFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".rdb"
|
rdbFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".rdb"
|
||||||
crlFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".crl"
|
crlFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".crl"
|
||||||
os.Remove(stashFile)
|
err = os.Remove(stashFile)
|
||||||
os.Remove(rdbFile)
|
if err != nil {
|
||||||
os.Remove(crlFile)
|
log.Errorf("Error removing %s: %v", stashFile, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = os.Remove(rdbFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Error removing %s: %v", rdbFile, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = os.Remove(crlFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Error removing %s: %v", crlFile, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = os.Remove(ks.Filename)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Error removing %s: %v", ks.Filename, err)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
os.Remove(ks.Filename)
|
|
||||||
} else if !os.IsNotExist(err) {
|
} else if !os.IsNotExist(err) {
|
||||||
// If the keystore exists but cannot be accessed then return the error
|
// If the keystore exists but cannot be accessed then return the error
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -30,13 +30,17 @@ import (
|
|||||||
var log *logger.Logger
|
var log *logger.Logger
|
||||||
|
|
||||||
func setPassword(user string, password string) error {
|
func setPassword(user string, password string) error {
|
||||||
|
// #nosec G204
|
||||||
cmd := exec.Command("chpasswd")
|
cmd := exec.Command("chpasswd")
|
||||||
stdin, err := cmd.StdinPipe()
|
stdin, err := cmd.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Fprintf(stdin, "%s:%s", user, password)
|
fmt.Fprintf(stdin, "%s:%s", user, password)
|
||||||
stdin.Close()
|
err = stdin.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Error closing password stdin: %v", err)
|
||||||
|
}
|
||||||
_, _, err = command.RunCmd(cmd)
|
_, _, err = command.RunCmd(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -165,6 +169,10 @@ func main() {
|
|||||||
osExit(1)
|
osExit(1)
|
||||||
} else {
|
} else {
|
||||||
// Replace this process with runmqserver
|
// Replace this process with runmqserver
|
||||||
syscall.Exec("/usr/local/bin/runmqserver", []string{"runmqserver"}, os.Environ())
|
// #nosec G204
|
||||||
|
err = syscall.Exec("/usr/local/bin/runmqserver", []string{"runmqserver"}, os.Environ())
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Error replacing this process with runmqserver: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,14 @@ func updateMQSC(appPasswordRequired bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
os.Remove(mqsc)
|
_, err := os.Stat(mqsc)
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
err = os.Remove(mqsc)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Error removing file %s: %v", mqsc, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,11 @@ func processTemplateFile(templateFile, destFile string, data interface{}) error
|
|||||||
_, err = os.Stat(dir)
|
_, err = os.Stat(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
os.MkdirAll(dir, 0660)
|
err = os.MkdirAll(dir, 0660)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
mqmUID, mqmGID, err := command.LookupMQM()
|
mqmUID, mqmGID, err := command.LookupMQM()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
@@ -51,6 +55,7 @@ func processTemplateFile(templateFile, destFile string, data interface{}) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// #nosec G302
|
||||||
f, err := os.OpenFile(destFile, os.O_CREATE|os.O_WRONLY, 0660)
|
f, err := os.OpenFile(destFile, os.O_CREATE|os.O_WRONLY, 0660)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
err = t.Execute(f, data)
|
err = t.Execute(f, data)
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ func configureTLS(qmName string, inputFile string, passPhrase string) error {
|
|||||||
_, err = os.Stat(dir)
|
_, err = os.Stat(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
// #nosec G301
|
||||||
err = os.MkdirAll(dir, 0770)
|
err = os.MkdirAll(dir, 0770)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ func createVolume(path string) error {
|
|||||||
fi, err := os.Stat(dataPath)
|
fi, err := os.Stat(dataPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
// #nosec G301
|
||||||
err = os.MkdirAll(dataPath, 0755)
|
err = os.MkdirAll(dataPath, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ func checkLicense() (bool, error) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
case ok && lic == "view":
|
case ok && lic == "view":
|
||||||
file := filepath.Join("/opt/mqm/licenses", resolveLicenseFile())
|
file := filepath.Join("/opt/mqm/licenses", resolveLicenseFile())
|
||||||
|
// #nosec G304
|
||||||
buf, err := ioutil.ReadFile(file)
|
buf, err := ioutil.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/command"
|
||||||
"github.com/ibm-messaging/mq-container/internal/logger"
|
"github.com/ibm-messaging/mq-container/internal/logger"
|
||||||
"github.com/ibm-messaging/mq-container/internal/mqini"
|
"github.com/ibm-messaging/mq-container/internal/mqini"
|
||||||
)
|
)
|
||||||
@@ -31,6 +33,8 @@ import (
|
|||||||
// var debug = false
|
// var debug = false
|
||||||
var log *logger.Logger
|
var log *logger.Logger
|
||||||
|
|
||||||
|
var collectDiagOnFail = false
|
||||||
|
|
||||||
func logTerminationf(format string, args ...interface{}) {
|
func logTerminationf(format string, args ...interface{}) {
|
||||||
logTermination(fmt.Sprintf(format, args))
|
logTermination(fmt.Sprintf(format, args))
|
||||||
}
|
}
|
||||||
@@ -45,6 +49,10 @@ func logTermination(args ...interface{}) {
|
|||||||
log.Debug(err)
|
log.Debug(err)
|
||||||
}
|
}
|
||||||
log.Error(msg)
|
log.Error(msg)
|
||||||
|
|
||||||
|
if collectDiagOnFail {
|
||||||
|
logDiagnostics()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLogFormat() string {
|
func getLogFormat() string {
|
||||||
@@ -100,8 +108,12 @@ func configureLogger(name string) (mirrorFunc, error) {
|
|||||||
return func(msg string) {
|
return func(msg string) {
|
||||||
// Parse the JSON message, and print a simplified version
|
// Parse the JSON message, and print a simplified version
|
||||||
var obj map[string]interface{}
|
var obj map[string]interface{}
|
||||||
json.Unmarshal([]byte(msg), &obj)
|
err := json.Unmarshal([]byte(msg), &obj)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to Unmarshall JSON - %v", err)
|
||||||
|
} else {
|
||||||
fmt.Printf(formatSimple(obj["ibm_datetime"].(string), obj["message"].(string)))
|
fmt.Printf(formatSimple(obj["ibm_datetime"].(string), obj["message"].(string)))
|
||||||
|
}
|
||||||
}, nil
|
}, nil
|
||||||
default:
|
default:
|
||||||
log, err = logger.NewLogger(os.Stdout, d, false, name)
|
log, err = logger.NewLogger(os.Stdout, d, false, name)
|
||||||
@@ -111,3 +123,34 @@ func configureLogger(name string) (mirrorFunc, error) {
|
|||||||
return nil, fmt.Errorf("invalid value for LOG_FORMAT: %v", f)
|
return nil, fmt.Errorf("invalid value for LOG_FORMAT: %v", f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func logDiagnostics() {
|
||||||
|
log.Debug("--- Start Diagnostics ---")
|
||||||
|
|
||||||
|
// show the directory ownership/permissions
|
||||||
|
// #nosec G104
|
||||||
|
out, _, _ := command.Run("ls", "-l", "/mnt/")
|
||||||
|
log.Debugf("/mnt/:\n%s", out)
|
||||||
|
// #nosec G104
|
||||||
|
out, _, _ = command.Run("ls", "-l", "/mnt/mqm")
|
||||||
|
log.Debugf("/mnt/mqm:\n%s", out)
|
||||||
|
// #nosec G104
|
||||||
|
out, _, _ = command.Run("ls", "-l", "/mnt/mqm/data")
|
||||||
|
log.Debugf("/mnt/mqm/data:\n%s", out)
|
||||||
|
// #nosec G104
|
||||||
|
out, _, _ = command.Run("ls", "-l", "/var/mqm")
|
||||||
|
log.Debugf("/var/mqm:\n%s", out)
|
||||||
|
// #nosec G104
|
||||||
|
out, _, _ = command.Run("ls", "-l", "/var/mqm/errors")
|
||||||
|
log.Debugf("/var/mqm/errors:\n%s", out)
|
||||||
|
|
||||||
|
// Print out summary of any FDCs
|
||||||
|
// #nosec G204
|
||||||
|
cmd := exec.Command("/opt/mqm/bin/ffstsummary")
|
||||||
|
cmd.Dir = "/var/mqm/errors"
|
||||||
|
// #nosec G104
|
||||||
|
outB, _ := cmd.CombinedOutput()
|
||||||
|
log.Debugf("ffstsummary:\n%s", string(outB))
|
||||||
|
|
||||||
|
log.Debug("--- End Diagnostics ---")
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,12 +58,21 @@ func doMain() error {
|
|||||||
|
|
||||||
// Start signal handler
|
// Start signal handler
|
||||||
signalControl := signalHandler(name)
|
signalControl := signalHandler(name)
|
||||||
|
// Enable diagnostic collecting on failure
|
||||||
|
collectDiagOnFail = true
|
||||||
|
|
||||||
|
err = verifyCurrentUser()
|
||||||
|
if err != nil {
|
||||||
|
logTermination(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = logConfig()
|
err = logConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logTermination(err)
|
logTermination(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createVolume("/mnt/mqm")
|
err = createVolume("/mnt/mqm")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logTermination(err)
|
logTermination(err)
|
||||||
@@ -120,7 +129,11 @@ func doMain() error {
|
|||||||
logTermination(err)
|
logTermination(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
configureQueueManager()
|
err = configureQueueManager()
|
||||||
|
if err != nil {
|
||||||
|
logTermination(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
enableMetrics := os.Getenv("MQ_ENABLE_METRICS")
|
enableMetrics := os.Getenv("MQ_ENABLE_METRICS")
|
||||||
if enableMetrics == "true" || enableMetrics == "1" {
|
if enableMetrics == "true" || enableMetrics == "1" {
|
||||||
@@ -136,7 +149,11 @@ func doMain() error {
|
|||||||
// Reap zombies now, just in case we've already got some
|
// Reap zombies now, just in case we've already got some
|
||||||
signalControl <- reapNow
|
signalControl <- reapNow
|
||||||
// Write a file to indicate that chkmqready should now work as normal
|
// Write a file to indicate that chkmqready should now work as normal
|
||||||
ready.Set()
|
err = ready.Set()
|
||||||
|
if err != nil {
|
||||||
|
logTermination(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
// Wait for terminate signal
|
// Wait for terminate signal
|
||||||
<-signalControl
|
<-signalControl
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ func waitForFile(ctx context.Context, path string) (os.FileInfo, error) {
|
|||||||
return nil, fmt.Errorf("mirror: unable to get info on file %v", path)
|
return nil, fmt.Errorf("mirror: unable to get info on file %v", path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Debugf("File exists: %v, %v", path, fi.Size())
|
|
||||||
return fi, nil
|
return fi, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,6 +120,7 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b
|
|||||||
if fi == nil {
|
if fi == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.Debugf("File exists: %v, %v", path, fi.Size())
|
||||||
f, err = os.OpenFile(path, os.O_RDONLY, 0)
|
f, err = os.OpenFile(path, os.O_RDONLY, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
@@ -139,7 +139,10 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b
|
|||||||
// Always start at the beginning if we've been told to go from the start
|
// Always start at the beginning if we've been told to go from the start
|
||||||
if offset != 0 && !fromStart {
|
if offset != 0 && !fromStart {
|
||||||
log.Debugf("Seeking offset %v in file %v", offset, path)
|
log.Debugf("Seeking offset %v in file %v", offset, path)
|
||||||
f.Seek(offset, 0)
|
_, err = f.Seek(offset, 0)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Unable to return to offset %v: %v", offset, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
closing := false
|
closing := false
|
||||||
for {
|
for {
|
||||||
@@ -159,7 +162,10 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b
|
|||||||
// could skip all those messages. This could happen with a very small
|
// could skip all those messages. This could happen with a very small
|
||||||
// MQ error log size.
|
// MQ error log size.
|
||||||
mirrorAvailableMessages(f, mf)
|
mirrorAvailableMessages(f, mf)
|
||||||
f.Close()
|
err = f.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Unable to close mirror file handle: %v", err)
|
||||||
|
}
|
||||||
// Re-open file
|
// Re-open file
|
||||||
log.Debugf("Re-opening error log file %v", path)
|
log.Debugf("Re-opening error log file %v", path)
|
||||||
f, err = os.OpenFile(path, os.O_RDONLY, 0)
|
f, err = os.OpenFile(path, os.O_RDONLY, 0)
|
||||||
|
|||||||
@@ -18,26 +18,26 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os/user"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/genuinetools/amicontained/container"
|
"github.com/genuinetools/amicontained/container"
|
||||||
)
|
)
|
||||||
|
|
||||||
func logContainerRuntime() error {
|
func logContainerRuntime() {
|
||||||
r, err := container.DetectRuntime()
|
r, err := container.DetectRuntime()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
log.Printf("Failed to get container runtime: %v", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
log.Printf("Container runtime: %v", r)
|
log.Printf("Container runtime: %v", r)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func logBaseImage() error {
|
func logBaseImage() {
|
||||||
buf, err := ioutil.ReadFile("/etc/os-release")
|
buf, err := ioutil.ReadFile("/etc/os-release")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
log.Printf("Failed to read /etc/os-release: %v", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
lines := strings.Split(string(buf), "\n")
|
lines := strings.Split(string(buf), "\n")
|
||||||
for _, l := range lines {
|
for _, l := range lines {
|
||||||
@@ -45,60 +45,40 @@ func logBaseImage() error {
|
|||||||
words := strings.Split(l, "\"")
|
words := strings.Split(l, "\"")
|
||||||
if len(words) >= 2 {
|
if len(words) >= 2 {
|
||||||
log.Printf("Base image: %v", words[1])
|
log.Printf("Base image: %v", words[1])
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func logUser() {
|
|
||||||
u, err := user.Current()
|
|
||||||
if err == nil {
|
|
||||||
g, err := u.GroupIds()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Running as user ID %v (%v) with primary group %v", u.Uid, u.Name, u.Gid)
|
|
||||||
} else {
|
|
||||||
// Look for the primary group in the list of group IDs
|
|
||||||
for i, v := range g {
|
|
||||||
if v == u.Gid {
|
|
||||||
// Remove the element from the slice
|
|
||||||
g = append(g[:i], g[i+1:]...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.Printf("Running as user ID %v (%v) with primary group %v, and supplemental groups %v", u.Uid, u.Name, u.Gid, strings.Join(g, ","))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// logCapabilities logs the Linux capabilities (e.g. setuid, setgid). See https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
|
// logCapabilities logs the Linux capabilities (e.g. setuid, setgid). See https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
|
||||||
func logCapabilities() error {
|
func logCapabilities() {
|
||||||
caps, err := container.Capabilities()
|
caps, err := container.Capabilities()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
log.Printf("Failed to get container capabilities: %v", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
for k, v := range caps {
|
for k, v := range caps {
|
||||||
if len(v) > 0 {
|
if len(v) > 0 {
|
||||||
log.Printf("Capabilities (%s set): %v", strings.ToLower(k), strings.Join(v, ","))
|
log.Printf("Capabilities (%s set): %v", strings.ToLower(k), strings.Join(v, ","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// logSeccomp logs the seccomp enforcing mode, which affects which kernel calls can be made
|
// logSeccomp logs the seccomp enforcing mode, which affects which kernel calls can be made
|
||||||
func logSeccomp() error {
|
func logSeccomp() {
|
||||||
s, err := container.SeccompEnforcingMode()
|
s, err := container.SeccompEnforcingMode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
log.Printf("Failed to get container SeccompEnforcingMode: %v", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
log.Printf("seccomp enforcing mode: %v", s)
|
log.Printf("seccomp enforcing mode: %v", s)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// logSecurityAttributes logs the security attributes of the current process.
|
// logSecurityAttributes logs the security attributes of the current process.
|
||||||
// The security attributes indicate whether AppArmor or SELinux are being used,
|
// The security attributes indicate whether AppArmor or SELinux are being used,
|
||||||
// and what the level of confinement is.
|
// and what the level of confinement is.
|
||||||
func logSecurityAttributes() error {
|
func logSecurityAttributes() {
|
||||||
a, err := readProc("/proc/self/attr/current")
|
a, err := readProc("/proc/self/attr/current")
|
||||||
// On some systems, if AppArmor or SELinux are not installed, you get an
|
// On some systems, if AppArmor or SELinux are not installed, you get an
|
||||||
// error when you try and read `/proc/self/attr/current`, even though the
|
// error when you try and read `/proc/self/attr/current`, even though the
|
||||||
@@ -107,10 +87,10 @@ func logSecurityAttributes() error {
|
|||||||
a = "none"
|
a = "none"
|
||||||
}
|
}
|
||||||
log.Printf("Process security attributes: %v", a)
|
log.Printf("Process security attributes: %v", a)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func readProc(filename string) (value string, err error) {
|
func readProc(filename string) (value string, err error) {
|
||||||
|
// #nosec G304
|
||||||
buf, err := ioutil.ReadFile(filename)
|
buf, err := ioutil.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ func configureQueueManager() error {
|
|||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if strings.HasSuffix(file.Name(), ".mqsc") {
|
if strings.HasSuffix(file.Name(), ".mqsc") {
|
||||||
abs := filepath.Join(configDir, file.Name())
|
abs := filepath.Join(configDir, file.Name())
|
||||||
|
// #nosec G204
|
||||||
cmd := exec.Command("runmqsc")
|
cmd := exec.Command("runmqsc")
|
||||||
stdin, err := cmd.StdinPipe()
|
stdin, err := cmd.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -97,6 +98,7 @@ func configureQueueManager() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Open the MQSC file for reading
|
// Open the MQSC file for reading
|
||||||
|
// #nosec G304
|
||||||
f, err := os.Open(abs)
|
f, err := os.Open(abs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error opening %v: %v", abs, err)
|
log.Printf("Error opening %v: %v", abs, err)
|
||||||
@@ -104,10 +106,16 @@ func configureQueueManager() error {
|
|||||||
// Copy the contents to stdin of the runmqsc process
|
// Copy the contents to stdin of the runmqsc process
|
||||||
_, err = io.Copy(stdin, f)
|
_, err = io.Copy(stdin, f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error reading %v: %v", abs, err)
|
log.Errorf("Error reading %v: %v", abs, err)
|
||||||
|
}
|
||||||
|
err = f.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to close MQSC file handle: %v", err)
|
||||||
|
}
|
||||||
|
err = stdin.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to close MQSC stdin: %v", err)
|
||||||
}
|
}
|
||||||
f.Close()
|
|
||||||
stdin.Close()
|
|
||||||
// Run the command and wait for completion
|
// Run the command and wait for completion
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ func signalHandler(qmgr string) chan int {
|
|||||||
log.Printf("Signal received: %v", sig)
|
log.Printf("Signal received: %v", sig)
|
||||||
signal.Stop(reapSignals)
|
signal.Stop(reapSignals)
|
||||||
signal.Stop(stopSignals)
|
signal.Stop(stopSignals)
|
||||||
metrics.StopMetricsGathering()
|
metrics.StopMetricsGathering(log)
|
||||||
|
// #nosec G104
|
||||||
stopQueueManager(qmgr)
|
stopQueueManager(qmgr)
|
||||||
// One final reap
|
// One final reap
|
||||||
reapZombies()
|
reapZombies()
|
||||||
|
|||||||
137
cmd/runmqserver/user.go
Normal file
137
cmd/runmqserver/user.go
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
© 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.
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/user"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/command"
|
||||||
|
)
|
||||||
|
|
||||||
|
const groupName string = "supplgrp"
|
||||||
|
|
||||||
|
func verifyCurrentUser() error {
|
||||||
|
log.Debug("Verifying current user information")
|
||||||
|
curUser, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Debugf("Detected current user as: %v+", curUser)
|
||||||
|
if curUser.Username == "mqm" {
|
||||||
|
// Not supported yet
|
||||||
|
return fmt.Errorf("Container is running as mqm user which is not supported. Please run this container as root")
|
||||||
|
} else if curUser.Username == "root" {
|
||||||
|
// We're running as root so need to check for supplementary groups.
|
||||||
|
// We can't use the golang User.GroupIDs as it doesn't seem to detect container supplementary groups..
|
||||||
|
groups, err := getCurrentUserGroups()
|
||||||
|
for _, e := range groups {
|
||||||
|
_, _, testGroup := command.Run("getent", "group", e)
|
||||||
|
if testGroup != nil {
|
||||||
|
log.Printf("Group %s does not exist on the system... Adding to system and MQM user", e)
|
||||||
|
_, _, err = command.Run("groupadd", "-g", e, groupName)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to create group %s as %s", e, groupName)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, _, err = command.Run("usermod", "-aG", groupName, "mqm")
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to add group %s(%s) to the mqm user.", groupName, e)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// We're running as an unknown user...
|
||||||
|
return fmt.Errorf("Container is running as %s user which is not supported. Please run this container as root", curUser.Username)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func logUser() {
|
||||||
|
u, usererr := user.Current()
|
||||||
|
if usererr == nil {
|
||||||
|
g, err := getCurrentUserGroups()
|
||||||
|
if err != nil && len(g) == 0 {
|
||||||
|
log.Printf("Running as user ID %v (%v) with primary group %v", u.Uid, u.Name, u.Gid)
|
||||||
|
} else {
|
||||||
|
// Look for the primary group in the list of group IDs
|
||||||
|
for i, v := range g {
|
||||||
|
if v == u.Gid {
|
||||||
|
// Remove the element from the slice
|
||||||
|
g = append(g[:i], g[i+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Printf("Running as user ID %v (%v) with primary group %v, and supplementary groups %v", u.Uid, u.Name, u.Gid, strings.Join(g, ","))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if usererr == nil && u.Username != "mqm" {
|
||||||
|
mqm, err := user.Lookup("mqm")
|
||||||
|
// Need to print out mqm user details as well.
|
||||||
|
g, err := getUserGroups(mqm)
|
||||||
|
if err != nil && len(g) == 0 {
|
||||||
|
log.Printf("MQM user ID %v (%v) has primary group %v", mqm.Uid, "mqm", mqm.Gid)
|
||||||
|
} else {
|
||||||
|
// Look for the primary group in the list of group IDs
|
||||||
|
for i, v := range g {
|
||||||
|
if v == mqm.Gid {
|
||||||
|
// Remove the element from the slice
|
||||||
|
g = append(g[:i], g[i+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Printf("MQM user ID %v (%v) has primary group %v, and supplementary groups %v", mqm.Uid, "mqm", mqm.Gid, strings.Join(g, ","))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCurrentUserGroups() ([]string, error) {
|
||||||
|
var nilArray []string
|
||||||
|
out, _, err := command.Run("id", "--groups")
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("Unable to get current user groups")
|
||||||
|
return nilArray, err
|
||||||
|
}
|
||||||
|
|
||||||
|
out = strings.TrimSpace(out)
|
||||||
|
if out == "" {
|
||||||
|
// we don't have any groups?
|
||||||
|
return nilArray, fmt.Errorf("Unable to determine groups for current user")
|
||||||
|
}
|
||||||
|
|
||||||
|
groups := strings.Split(out, " ")
|
||||||
|
return groups, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getUserGroups(usr *user.User) ([]string, error) {
|
||||||
|
var nilArray []string
|
||||||
|
out, _, err := command.Run("id", "--groups", usr.Uid)
|
||||||
|
if err != nil {
|
||||||
|
log.Debugf("Unable to get user %s groups", usr.Uid)
|
||||||
|
return nilArray, err
|
||||||
|
}
|
||||||
|
|
||||||
|
out = strings.TrimSpace(out)
|
||||||
|
if out == "" {
|
||||||
|
// we don't have any groups?
|
||||||
|
return nilArray, fmt.Errorf("Unable to determine groups for user %s", usr.Uid)
|
||||||
|
}
|
||||||
|
|
||||||
|
groups := strings.Split(out, " ")
|
||||||
|
return groups, nil
|
||||||
|
}
|
||||||
@@ -23,8 +23,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// ImageCreated is the date the image was built
|
||||||
ImageCreated = "Not specified"
|
ImageCreated = "Not specified"
|
||||||
|
// ImageRevision is the source control revision identifier
|
||||||
ImageRevision = "Not specified"
|
ImageRevision = "Not specified"
|
||||||
|
// ImageSource is the URL to get source code for building the image
|
||||||
ImageSource = "Not specified"
|
ImageSource = "Not specified"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/ibm-messaging/mq-container/internal/command"
|
"github.com/ibm-messaging/mq-container/internal/command"
|
||||||
)
|
)
|
||||||
@@ -33,7 +35,20 @@ func startWebServer() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Println("Starting web server")
|
log.Println("Starting web server")
|
||||||
out, rc, err := command.RunAsMQM("strmqweb")
|
cmd := exec.Command("strmqweb")
|
||||||
|
// Set a default app password for the web server, if one isn't already set
|
||||||
|
_, set := os.LookupEnv("MQ_APP_PASSWORD")
|
||||||
|
if !set {
|
||||||
|
// Take all current environment variables, and add the app password
|
||||||
|
cmd.Env = append(os.Environ(), "MQ_APP_PASSWORD=passw0rd")
|
||||||
|
}
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||||
|
uid, gid, err := command.LookupMQM()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
|
||||||
|
out, rc, err := command.RunCmd(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error %v starting web server: %v", rc, string(out))
|
log.Printf("Error %v starting web server: %v", rc, string(out))
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,25 +1,46 @@
|
|||||||
# Building a Docker image
|
# Building a container image
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
You need to ensure you have the following tools installed:
|
|
||||||
|
### Prerequisites for building an Ubuntu image
|
||||||
|
If you want to build a container image with Ubuntu Linux as the base OS, then you need to have the following tools installed:
|
||||||
|
|
||||||
* [Docker](https://www.docker.com/) V17.06.1 or later
|
* [Docker](https://www.docker.com/) V17.06.1 or later
|
||||||
* [GNU make](https://www.gnu.org/software/make/)
|
* [GNU make](https://www.gnu.org/software/make/)
|
||||||
|
|
||||||
If you are working in the Windows Subsystem for Linux, follow [this guide by Microsoft to set up Docker](https://blogs.msdn.microsoft.com/commandline/2017/12/08/cross-post-wsl-interoperability-with-docker/) first.
|
If you are working in the Windows Subsystem for Linux, follow [this guide by Microsoft to set up Docker](https://blogs.msdn.microsoft.com/commandline/2017/12/08/cross-post-wsl-interoperability-with-docker/) first.
|
||||||
|
|
||||||
|
### Prerequisites for building a Red Hat Enterprise Linux image
|
||||||
|
If you want to build a container image with Red Hat Enterprise Linux as the base OS, then you need to use a host server with Red Hat Enterprise Linux. You must also have the following tools installed:
|
||||||
|
|
||||||
|
* [`buildah`](https://buildah.io) (available in `rhel-7-server-extras`)
|
||||||
|
* [`podman`](https://podman.io) (available in `rhel-7-server-extras`)
|
||||||
|
|
||||||
|
In addition, you need the following commonly installed tools:
|
||||||
|
|
||||||
|
* `bash`
|
||||||
|
* `coreutils`
|
||||||
|
* `findutils`
|
||||||
|
* `make`
|
||||||
|
* `sed`
|
||||||
|
* `shadow-utils`
|
||||||
|
* `tar`
|
||||||
|
|
||||||
## Building a production image
|
## Building a production image
|
||||||
This procedure works for building the MQ Continuous Delivery release, on `x86_64`, `ppc64le` and `s390x` architectures.
|
This procedure works for building the MQ Continuous Delivery release, on `x86_64`, `ppc64le` and `s390x` architectures.
|
||||||
|
|
||||||
1. Create a `downloads` directory in the root of this repository
|
1. Create a `downloads` directory in the root of this repository
|
||||||
2. Download MQ from IBM Passport Advantage, and place the downloaded file (for example, `IBM_MQ_9.1.0.0_UBUNTU_X86-64.tar.gz` for MQ V9.1.0 for Ubuntu on x86_64 architecture) in the `downloads` directory
|
2. Download MQ from [IBM Passport Advantage](https://www.ibm.com/software/passportadvantage/) or [IBM Fix Central](https://www.ibm.com/support/fixcentral), and place the downloaded file (for example, `IBM_MQ_9.1.1_UBUNTU_X86-64.tar.gz` for MQ V9.1.1 for Ubuntu on x86_64 architecture) in the `downloads` directory
|
||||||
2. Run `make build-advancedserver`
|
3. Run `make build-advancedserver`
|
||||||
|
|
||||||
> **Warning**: Note that MQ offers two different sets of packaging on Linux: one is called "MQ for Linux" and contains RPM files for installing on Red Hat Enterprise Linux and SUSE Linux Enterprise Server. The other package is called "MQ for Ubuntu", and contains DEB files for installing on Ubuntu.
|
> **Warning**: Note that MQ offers two different sets of packaging on Linux: one is called "MQ for Linux" and contains RPM files for installing on Red Hat Enterprise Linux and SUSE Linux Enterprise Server. The other package is called "MQ for Ubuntu", and contains DEB files for installing on Ubuntu.
|
||||||
|
|
||||||
|
On a Red Hat Enterprise Linux host, the command `make build-advancedserver` will build a container image using Red Hat Enterprise Linux as the base. On all other hosts, the base image will be Ubuntu.
|
||||||
|
|
||||||
You can build a different version of MQ by setting the `MQ_VERSION` environment variable, for example:
|
You can build a different version of MQ by setting the `MQ_VERSION` environment variable, for example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
MQ_VERSION=9.0.5.0 make build-advancedserver
|
MQ_VERSION=9.1.0.0 make build-advancedserver
|
||||||
```
|
```
|
||||||
|
|
||||||
If you have an MQ archive file with a different file name, you can specify a particular file (which must be in the `downloads` directory). You should also specify the MQ version, so that the resulting image is tagged correctly, for example:
|
If you have an MQ archive file with a different file name, you can specify a particular file (which must be in the `downloads` directory). You should also specify the MQ version, so that the resulting image is tagged correctly, for example:
|
||||||
@@ -29,22 +50,10 @@ MQ_ARCHIVE=mq-1.2.3.4.tar.gz MQ_VERSION=1.2.3.4 make build-advancedserver
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Building a developer image
|
## Building a developer image
|
||||||
Run `make build-devserver`, which will download the latest version of MQ Advanced for Developers from IBM developerWorks. This is currently only available on the `x86_64` architecture.
|
Run `make build-devserver`, which will download the latest version of MQ Advanced for Developers from IBM developerWorks. This is currently only available on the `x86_64` architecture. On a Red Hat Enterprise Linux host, this command will build a container image using Red Hat Enterprise Linux as the base. On all other hosts, the base image will be Ubuntu.
|
||||||
|
|
||||||
You can use the environment variable `MQ_ARCHIVE_DEV` to specify an alternative local file to install from (which must be in the `downloads` directory).
|
You can use the environment variable `MQ_ARCHIVE_DEV` to specify an alternative local file to install from (which must be in the `downloads` directory).
|
||||||
|
|
||||||
## Building on a different base image
|
|
||||||
By default, the MQ images use Ubuntu as the base layer. You can build using a Red Hat Enterprise Linux compatible base layer by setting the `BASE_IMAGE` environment variable. For example:
|
|
||||||
|
|
||||||
```
|
|
||||||
BASE_IMAGE=centos:7 make build-advancedserver
|
|
||||||
```
|
|
||||||
|
|
||||||
The `make` tool will try and locate the right archive file under the `downloads` directory, based on your platform architecture and your `MQ_VERSION` environment variable, for example `IBM_MQ_9.1.0.0_LINUX_X86_64.tar.gz` for MQ V9.1.0.0 on x86_64. You can also set the `MQ_ARCHIVE` environment variable to set the specific file name.
|
|
||||||
|
|
||||||
Note that if you are using Red Hat Enterprise Linux, you will need to create your own base image layer, with your subscription enabled, as described [here](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_atomic_host/7/html/getting_started_with_containers/get_started_with_docker_formatted_container_images). The MQ image build needs to install some additional packages, and a subscription is required to access the Red Hat repositories.
|
|
||||||
|
|
||||||
|
|
||||||
## Installed components
|
## Installed components
|
||||||
|
|
||||||
This image includes the core MQ server, Java, language packs, and GSKit. This can be configured by setting the `MQ_PACKAGES` argument to `make`, or directly as a [Docker build argument](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables-build-arg).
|
This image includes the core MQ server, Java, language packs, and GSKit. This can be configured by setting the `MQ_PACKAGES` argument to `make`. For the Ubuntu-based image, you can also directly set a [Docker build argument](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables-build-arg).
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ make test-advancedserver
|
|||||||
You can specify the image to use directly by using the `MQ_IMAGE_ADVANCEDSERVER` or `MQ_IMAGE_DEVSERVER` variables, for example:
|
You can specify the image to use directly by using the `MQ_IMAGE_ADVANCEDSERVER` or `MQ_IMAGE_DEVSERVER` variables, for example:
|
||||||
|
|
||||||
```
|
```
|
||||||
MQ_IMAGE_ADVANCEDSERVER=mqadvanced-server:9.1.0.0-x86_64-ubuntu-16.04 make test-advancedserver
|
MQ_IMAGE_ADVANCEDSERVER=mqadvanced-server:9.1.1.0-x86_64-ubuntu-16.04 make test-advancedserver
|
||||||
```
|
```
|
||||||
|
|
||||||
You can pass parameters to `go test` with an environment variable. For example, to run the "TestGoldenPath" test, run the following command::
|
You can pass parameters to `go test` with an environment variable. For example, to run the "TestGoldenPath" test, run the following command::
|
||||||
@@ -34,10 +34,10 @@ You can pass parameters to `go test` with an environment variable. For example,
|
|||||||
TEST_OPTS_DOCKER="-run TestGoldenPath" make test-advancedserver
|
TEST_OPTS_DOCKER="-run TestGoldenPath" make test-advancedserver
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also use the same environment variables you specified when [building](./building), for example, the following will try and test an image called `mqadvanced-server:9.0.5.0-x86_64-ubuntu-16.04`:
|
You can also use the same environment variables you specified when [building](./building), for example, the following will try and test an image called `mqadvanced-server:9.1.0.0-x86_64-ubuntu-16.04`:
|
||||||
|
|
||||||
```
|
```
|
||||||
MQ_VERSION=9.0.5.0 make test-advancedserver
|
MQ_VERSION=9.1.0.0 make test-advancedserver
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running the Docker tests with code coverage
|
### Running the Docker tests with code coverage
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ In order to use the image, it is necessary to accept the terms of the IBM MQ lic
|
|||||||
## Running with the default configuration
|
## Running with the default configuration
|
||||||
You can run a queue manager with the default configuration and a listener on port 1414 using the following command. For example, the following command creates and starts a queue manager called `QM1`, and maps port 1414 on the host to the MQ listener on port 1414 inside the container, as well as port 9443 on the host to the web console on port 9443 inside the container:
|
You can run a queue manager with the default configuration and a listener on port 1414 using the following command. For example, the following command creates and starts a queue manager called `QM1`, and maps port 1414 on the host to the MQ listener on port 1414 inside the container, as well as port 9443 on the host to the web console on port 9443 inside the container:
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker run \
|
docker run \
|
||||||
--env LICENSE=accept \
|
--env LICENSE=accept \
|
||||||
--env MQ_QMGR_NAME=QM1 \
|
--env MQ_QMGR_NAME=QM1 \
|
||||||
@@ -16,15 +16,15 @@ docker run \
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Running with the default configuration and a volume
|
## Running with the default configuration and a volume
|
||||||
The above example will not persist any configuration data or messages across container runs. In order to do this, you need to use a [volume](https://docs.docker.com/engine/admin/volumes/volumes/). For example, you can create a volume with the following command:
|
The above example will not persist any configuration data or messages across container runs. In order to do this, you need to use a [volume](https://docs.docker.com/storage/volumes/). For example, you can create a volume with the following command:
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker volume create qm1data
|
docker volume create qm1data
|
||||||
```
|
```
|
||||||
|
|
||||||
You can then run a queue manager using this volume as follows:
|
You can then run a queue manager using this volume as follows:
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker run \
|
docker run \
|
||||||
--env LICENSE=accept \
|
--env LICENSE=accept \
|
||||||
--env MQ_QMGR_NAME=QM1 \
|
--env MQ_QMGR_NAME=QM1 \
|
||||||
@@ -40,7 +40,7 @@ The Docker image always uses `/mnt/mqm` for MQ data, which is correctly linked f
|
|||||||
## Running with the default configuration and Prometheus metrics enabled
|
## Running with the default configuration and Prometheus metrics enabled
|
||||||
You can run a queue manager with [Prometheus](https://prometheus.io) metrics enabled. The following command will generate Prometheus metrics for your queue manager on `/metrics` port `9157`:
|
You can run a queue manager with [Prometheus](https://prometheus.io) metrics enabled. The following command will generate Prometheus metrics for your queue manager on `/metrics` port `9157`:
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker run \
|
docker run \
|
||||||
--env LICENSE=accept \
|
--env LICENSE=accept \
|
||||||
--env MQ_QMGR_NAME=QM1 \
|
--env MQ_QMGR_NAME=QM1 \
|
||||||
@@ -58,11 +58,11 @@ You can customize the configuration in several ways:
|
|||||||
|
|
||||||
1. For getting started, you can use the [default developer configuration](developer-config.md), which is available out-of-the-box for the MQ Advanced for Developers image
|
1. For getting started, you can use the [default developer configuration](developer-config.md), which is available out-of-the-box for the MQ Advanced for Developers image
|
||||||
2. By creating your own image and adding your own MQSC file into the `/etc/mqm` directory on the image. This file will be run when your queue manager is created.
|
2. By creating your own image and adding your own MQSC file into the `/etc/mqm` directory on the image. This file will be run when your queue manager is created.
|
||||||
3. By using [remote MQ administration](http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_9.0.0/com.ibm.mq.adm.doc/q021090_.htm), via an MQ command server, the MQ HTTP APIs, or using a tool such as the MQ web console or MQ Explorer.
|
3. By using [remote MQ administration](https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.1.0/com.ibm.mq.adm.doc/q021090_.htm), via an MQ command server, the MQ HTTP APIs, or using a tool such as the MQ web console or MQ Explorer.
|
||||||
|
|
||||||
Note that a listener is always created on port 1414 inside the container. This port can be mapped to any port on the Docker host.
|
Note that a listener is always created on port 1414 inside the container. This port can be mapped to any port on the Docker host.
|
||||||
|
|
||||||
The following is an *example* `Dockerfile` for creating your own pre-configured image, which adds a custom `config.mqsc` and an administrative user `alice`. Note that it is not normally recommended to include passwords in this way:
|
The following is an *example* `Dockerfile` for creating your own pre-configured image, which adds a custom MQ configuration file, and an administrative user `alice`. Note that it is not normally recommended to include passwords in this way:
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
FROM ibmcom/mq
|
FROM ibmcom/mq
|
||||||
@@ -71,9 +71,9 @@ RUN useradd alice -G mqm && \
|
|||||||
COPY 20-config.mqsc /etc/mqm/
|
COPY 20-config.mqsc /etc/mqm/
|
||||||
```
|
```
|
||||||
|
|
||||||
Here is an example corresponding `20-config.mqsc` script from the [mqdev blog](https://www.ibm.com/developerworks/community/blogs/messaging/entry/getting_going_without_turning_off_mq_security?lang=en), which allows users with passwords to connect on the `PASSWORD.SVRCONN` channel:
|
Here is an example corresponding `20-config.mqsc` script from the [mqdev blog](https://developer.ibm.com/messaging/2018/10/01/archives-getting-going-without-turning-off-ibm-mq-security/), which allows users with passwords to connect on the `PASSWORD.SVRCONN` channel:
|
||||||
|
|
||||||
```
|
```mqsc
|
||||||
DEFINE CHANNEL(PASSWORD.SVRCONN) CHLTYPE(SVRCONN) REPLACE
|
DEFINE CHANNEL(PASSWORD.SVRCONN) CHLTYPE(SVRCONN) REPLACE
|
||||||
SET CHLAUTH(PASSWORD.SVRCONN) TYPE(BLOCKUSER) USERLIST('nobody') DESCR('Allow privileged users on this channel')
|
SET CHLAUTH(PASSWORD.SVRCONN) TYPE(BLOCKUSER) USERLIST('nobody') DESCR('Allow privileged users on this channel')
|
||||||
SET CHLAUTH('*') TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(NOACCESS) DESCR('BackStop rule')
|
SET CHLAUTH('*') TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(NOACCESS) DESCR('BackStop rule')
|
||||||
@@ -82,10 +82,12 @@ ALTER AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) ADOPTCTX(YES)
|
|||||||
REFRESH SECURITY TYPE(CONNAUTH)
|
REFRESH SECURITY TYPE(CONNAUTH)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The file `20-config.mqsc` should be saved into the same directory as the `Dockerfile`.
|
||||||
|
|
||||||
## Running MQ commands
|
## Running MQ commands
|
||||||
It is recommended that you configure MQ in your own custom image. However, you may need to run MQ commands directly inside the process space of the container. To run a command against a running queue manager, you can use `docker exec`, for example:
|
It is recommended that you configure MQ in your own custom image. However, you may need to run MQ commands directly inside the process space of the container. To run a command against a running queue manager, you can use `docker exec`, for example:
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker exec \
|
docker exec \
|
||||||
--tty \
|
--tty \
|
||||||
--interactive \
|
--interactive \
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
FROM ubuntu:16.04
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
# The URL to download the MQ installer from in tar.gz format
|
# The URL to download the MQ installer from in tar.gz format
|
||||||
ARG MQ_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev903_ubuntu_x86-64.tar.gz
|
ARG MQ_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev911_ubuntu_x86-64.tar.gz
|
||||||
|
|
||||||
# The MQ packages to install
|
# The MQ packages to install
|
||||||
ARG MQ_PACKAGES="ibmmq-sfbridge"
|
ARG MQ_PACKAGES="ibmmq-sfbridge"
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
hosts
|
|
||||||
@@ -1,62 +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 golang
|
|
||||||
package:
|
|
||||||
name: golang
|
|
||||||
state: absent
|
|
||||||
- name: install make
|
|
||||||
package:
|
|
||||||
name: make
|
|
||||||
state: present
|
|
||||||
- name: install git
|
|
||||||
package:
|
|
||||||
name: git
|
|
||||||
state: present
|
|
||||||
- name: install golang 1.10 from TAR
|
|
||||||
unarchive:
|
|
||||||
src: "https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz"
|
|
||||||
dest: "/usr/local"
|
|
||||||
remote_src: yes
|
|
||||||
# TODO: Re-factor to use get_url first, so we can use the checksum
|
|
||||||
#checksum: sha256:fa1b0e45d3b647c252f51f5e1204aba049cde4af177ef9f2181f43004f901035
|
|
||||||
creates: /usr/local/go/doc/go1.10.html
|
|
||||||
- name: add golang to PATH
|
|
||||||
copy:
|
|
||||||
dest: "/etc/profile.d/golang.sh"
|
|
||||||
content: |
|
|
||||||
PATH=$PATH:/usr/local/go/bin
|
|
||||||
- name: install dep from GitHub
|
|
||||||
get_url:
|
|
||||||
url: https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64
|
|
||||||
dest: /usr/local/bin/dep
|
|
||||||
mode: 0755
|
|
||||||
checksum: sha256:31144e465e52ffbc0035248a10ddea61a09bf28b00784fd3fdd9882c8cbb2315
|
|
||||||
when: ansible_architecture == "x86_64"
|
|
||||||
# TODO: Install MQ SDK
|
|
||||||
@@ -1,141 +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_dev905_linux_x86-64.tar.gz
|
|
||||||
MQ_PACKAGES="MQSeriesRuntime-*.rpm MQSeriesServer-*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesMsg*.rpm MQSeriesSamples*.rpm MQSeriesAMS-*.rpm"
|
|
||||||
|
|
||||||
# Use a "scratch" container, so the resulting image has minimal files
|
|
||||||
# Resulting image won't have yum, for example
|
|
||||||
ctr=$(buildah from scratch)
|
|
||||||
scratchmnt=$(buildah mount $ctr)
|
|
||||||
|
|
||||||
# Initialize yum for use with the scratch container
|
|
||||||
rpm --root $scratchmnt --initdb
|
|
||||||
yum install yum-utils
|
|
||||||
yumdownloader --destdir=/tmp redhat-release-server
|
|
||||||
rpm --root $scratchmnt -ihv /tmp/redhat-release-server*.rpm
|
|
||||||
|
|
||||||
# Install the packages required by MQ
|
|
||||||
yum install -y --installroot=$scratchmnt \
|
|
||||||
bash \
|
|
||||||
bc \
|
|
||||||
coreutils \
|
|
||||||
file \
|
|
||||||
findutils \
|
|
||||||
gawk \
|
|
||||||
glibc-common \
|
|
||||||
grep \
|
|
||||||
passwd \
|
|
||||||
procps-ng \
|
|
||||||
sed \
|
|
||||||
tar \
|
|
||||||
util-linux
|
|
||||||
|
|
||||||
# Clean up cached files
|
|
||||||
yum clean all --installroot=$scratchmnt
|
|
||||||
rm -rf $scratchmnt/var/cache/yum/*
|
|
||||||
|
|
||||||
groupadd --root $scratchmnt --system --gid 888 mqm
|
|
||||||
useradd --root $scratchmnt --system --uid 888 --gid mqm mqm
|
|
||||||
usermod --root $scratchmnt -G root mqm
|
|
||||||
|
|
||||||
DIR_EXTRACT=$scratchmnt/tmp/extract
|
|
||||||
mkdir -p $scratchmnt/tmp/extract
|
|
||||||
tar -zxvf ${MQ_ARCHIVE} -C ${DIR_EXTRACT}
|
|
||||||
DIR_RPM=$(find ${DIR_EXTRACT} -name "*.rpm" -printf "%h\n" | sort -u | head -1)
|
|
||||||
DIR_RPM=${DIR_RPM#$scratchmnt}
|
|
||||||
#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#$scratchmnt}
|
|
||||||
|
|
||||||
# Accept the MQ license
|
|
||||||
buildah run $ctr -- ${MQLICENSE} -text_only -accept
|
|
||||||
|
|
||||||
buildah run $ctr -- bash -c "cd $DIR_RPM && 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
|
|
||||||
|
|
||||||
# Remove the directory structure under /var/mqm which was created by the installer
|
|
||||||
rm -rf $scratchmnt/var/mqm
|
|
||||||
|
|
||||||
# Create the mount point for volumes
|
|
||||||
mkdir -p $scratchmnt/mnt/mqm
|
|
||||||
|
|
||||||
# Create the directory for MQ configuration files
|
|
||||||
mkdir -p $scratchmnt/etc/mqm
|
|
||||||
|
|
||||||
# Create a symlink for /var/mqm -> /mnt/mqm/data
|
|
||||||
buildah run $ctr ln -s /mnt/mqm/data /var/mqm
|
|
||||||
|
|
||||||
# Optional: Set these values for the Bluemix 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
|
|
||||||
|
|
||||||
# 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/...
|
|
||||||
# Install the Go binaries into the image
|
|
||||||
cp runmqserver $scratchmnt/usr/local/bin/
|
|
||||||
cp chkmq* $scratchmnt/usr/local/bin/
|
|
||||||
cp NOTICES.txt $scratchmnt/opt/mqm/licenses/notices-container.txt
|
|
||||||
chmod ug+x $scratchmnt/usr/local/bin/runmqserver
|
|
||||||
chown mqm:mqm $scratchmnt/usr/local/bin/*mq*
|
|
||||||
chmod ug+xs $scratchmnt/usr/local/bin/chkmq*
|
|
||||||
|
|
||||||
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.0.5.0" \
|
|
||||||
--env AMQ_ADDITIONAL_JSON_LOG=1 \
|
|
||||||
--env LANG=en_US.UTF-8 \
|
|
||||||
--env LOG_FORMAT=basic \
|
|
||||||
--entrypoint runmqserver \
|
|
||||||
--user 888 \
|
|
||||||
$ctr
|
|
||||||
buildah unmount $ctr
|
|
||||||
buildah commit $ctr mymq
|
|
||||||
|
|
||||||
# TODO: Leaves the working container lying around. Good for dev.
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
FROM ubuntu:16.04
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
# The URL to download the MQ installer from in tar.gz format
|
# The URL to download the MQ installer from in tar.gz format
|
||||||
ARG MQ_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev903_ubuntu_x86-64.tar.gz
|
ARG MQ_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev911_ubuntu_x86-64.tar.gz
|
||||||
|
|
||||||
# The MQ packages to install
|
# The MQ packages to install
|
||||||
ARG MQ_PACKAGES="ibmmq-explorer"
|
ARG MQ_PACKAGES="ibmmq-explorer"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
ARG BASE_IMAGE=mq-sdk:9.0.5.0-x86_64-ubuntu-16.04
|
ARG BASE_IMAGE=mq-sdk:9.1.1.0-x86_64-ubuntu-16.04
|
||||||
|
|
||||||
FROM $BASE_IMAGE
|
FROM $BASE_IMAGE
|
||||||
|
|
||||||
|
|||||||
@@ -12,22 +12,21 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
ARG BASE_IMAGE=mqadvanced-server-dev-base:9.0.5.0-x86_64-ubuntu-16.04
|
ARG BASE_IMAGE=mqadvanced-server-dev-base:9.1.1.0-x86_64-ubuntu-16.04
|
||||||
ARG BUILDER_IMAGE=mq-golang-sdk:9.0.5.0-x86_64-ubuntu-16.04
|
ARG BUILDER_IMAGE=mq-golang-sdk:9.1.1.0-x86_64-ubuntu-16.04
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Build stage to build Go code
|
# Build stage to build Go code
|
||||||
###############################################################################
|
###############################################################################
|
||||||
FROM $BUILDER_IMAGE as builder
|
FROM $BUILDER_IMAGE as builder
|
||||||
ARG IMAGE_REVISION="Not specified"
|
ARG IMAGE_REVISION="Not specified"
|
||||||
ARG IMAGE_CREATED="Not specified"
|
|
||||||
ARG IMAGE_SOURCE="Not specified"
|
ARG IMAGE_SOURCE="Not specified"
|
||||||
WORKDIR /go/src/github.com/ibm-messaging/mq-container/
|
WORKDIR /go/src/github.com/ibm-messaging/mq-container/
|
||||||
COPY cmd/ ./cmd
|
COPY cmd/ ./cmd
|
||||||
COPY internal/ ./internal
|
COPY internal/ ./internal
|
||||||
COPY vendor/ ./vendor
|
COPY vendor/ ./vendor
|
||||||
# Re-build runmqserver, with code tagged with 'mqdev' enabled
|
# Re-build runmqserver, with code tagged with 'mqdev' enabled
|
||||||
RUN go build -ldflags "-X \"main.ImageCreated=$IMAGE_CREATED\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\"" --tags 'mqdev' ./cmd/runmqserver
|
RUN go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\"" --tags 'mqdev' ./cmd/runmqserver
|
||||||
RUN go build ./cmd/runmqdevserver/
|
RUN go build ./cmd/runmqdevserver/
|
||||||
# Run all unit tests
|
# Run all unit tests
|
||||||
RUN go test -v ./cmd/runmqdevserver/...
|
RUN go test -v ./cmd/runmqdevserver/...
|
||||||
|
|||||||
@@ -16,14 +16,25 @@
|
|||||||
<security-role name="MQWebAdmin">
|
<security-role name="MQWebAdmin">
|
||||||
<group name="MQWebUI" realm="defaultRealm"/>
|
<group name="MQWebUI" realm="defaultRealm"/>
|
||||||
</security-role>
|
</security-role>
|
||||||
|
<security-role name="MQWebUser">
|
||||||
|
<group name="MQWebMessaging" realm="defaultRealm"/>
|
||||||
|
</security-role>
|
||||||
</application-bnd>
|
</application-bnd>
|
||||||
</enterpriseApplication>
|
</enterpriseApplication>
|
||||||
<basicRegistry id="basic" realm="defaultRealm">
|
<basicRegistry id="basic" realm="defaultRealm">
|
||||||
<user name="admin" password="${env.MQ_ADMIN_PASSWORD}"/>
|
<user name="admin" password="${env.MQ_ADMIN_PASSWORD}"/>
|
||||||
|
<!-- The app user will always get a default password of "passw0rd",
|
||||||
|
even if you don't set the environment variable.
|
||||||
|
See `webserver.go` -->
|
||||||
|
<user name="app" password="${env.MQ_APP_PASSWORD}"/>
|
||||||
<group name="MQWebUI">
|
<group name="MQWebUI">
|
||||||
<member name="admin"/>
|
<member name="admin"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group name="MQWebMessaging">
|
||||||
|
<member name="app"/>
|
||||||
|
</group>
|
||||||
</basicRegistry>
|
</basicRegistry>
|
||||||
<variable name="httpHost" value="*"/>
|
<variable name="httpHost" value="*"/>
|
||||||
|
<variable name="managementMode" value="externallyprovisioned"/>
|
||||||
<include location="tls.xml"/>
|
<include location="tls.xml"/>
|
||||||
</server>
|
</server>
|
||||||
|
|||||||
26
install-build-deps-ubuntu.sh
Executable file
26
install-build-deps-ubuntu.sh
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: sh -*-
|
||||||
|
# © Copyright IBM Corporation 2015, 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 Docker and dep, required by build (assumes Ubuntu host, as used by Travis build)
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
curl https://glide.sh/get | sh
|
||||||
|
sudo curl -Lo /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64
|
||||||
|
sudo chmod +x /usr/local/bin/dep
|
||||||
|
|
||||||
|
go get golang.org/x/lint/golint
|
||||||
@@ -139,7 +139,7 @@ rm -rf ${DIR_EXTRACT}
|
|||||||
|
|
||||||
# Apply any bug fixes not included in base Ubuntu or MQ image.
|
# Apply any bug fixes not included in base Ubuntu or MQ image.
|
||||||
# Don't upgrade everything based on Docker best practices https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#run
|
# Don't upgrade everything based on Docker best practices https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#run
|
||||||
$UBUNTU && apt-get install -y gcc-5-base gnupg gpgv libgcrypt20 libstdc++6 perl-base --only-upgrade
|
$UBUNTU && apt-get install -y libapparmor1 libsystemd0 systemd systemd-sysv libudev1 --only-upgrade
|
||||||
# End of bug fixes
|
# End of bug fixes
|
||||||
|
|
||||||
# Clean up cached files
|
# Clean up cached files
|
||||||
|
|||||||
@@ -53,11 +53,13 @@ func RunCmd(cmd *exec.Cmd) (string, int, error) {
|
|||||||
// Do not use this function to run shell built-ins (like "cd"), because
|
// Do not use this function to run shell built-ins (like "cd"), because
|
||||||
// the error handling works differently
|
// the error handling works differently
|
||||||
func Run(name string, arg ...string) (string, int, error) {
|
func Run(name string, arg ...string) (string, int, error) {
|
||||||
|
// #nosec G204
|
||||||
return RunCmd(exec.Command(name, arg...))
|
return RunCmd(exec.Command(name, arg...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunAsMQM runs the specified command as the mqm user
|
// RunAsMQM runs the specified command as the mqm user
|
||||||
func RunAsMQM(name string, arg ...string) (string, int, error) {
|
func RunAsMQM(name string, arg ...string) (string, int, error) {
|
||||||
|
// #nosec G204
|
||||||
cmd := exec.Command(name, arg...)
|
cmd := exec.Command(name, arg...)
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||||
uid, gid, err := LookupMQM()
|
uid, gid, err := LookupMQM()
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func GatherMetrics(qmName string, log *logger.Logger) {
|
|||||||
err := startMetricsGathering(qmName, log)
|
err := startMetricsGathering(qmName, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Metrics Error: %s", err.Error())
|
log.Errorf("Metrics Error: %s", err.Error())
|
||||||
StopMetricsGathering()
|
StopMetricsGathering(log)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +76,7 @@ func startMetricsGathering(qmName string, log *logger.Logger) error {
|
|||||||
http.Handle("/metrics", prometheus.Handler())
|
http.Handle("/metrics", prometheus.Handler())
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
|
// #nosec G104
|
||||||
w.Write([]byte("Status: METRICS ACTIVE"))
|
w.Write([]byte("Status: METRICS ACTIVE"))
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ func startMetricsGathering(qmName string, log *logger.Logger) error {
|
|||||||
err = metricsServer.ListenAndServe()
|
err = metricsServer.ListenAndServe()
|
||||||
if err != nil && err != http.ErrServerClosed {
|
if err != nil && err != http.ErrServerClosed {
|
||||||
log.Errorf("Metrics Error: Failed to handle metrics request: %v", err)
|
log.Errorf("Metrics Error: Failed to handle metrics request: %v", err)
|
||||||
StopMetricsGathering()
|
StopMetricsGathering(log)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ func startMetricsGathering(qmName string, log *logger.Logger) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StopMetricsGathering stops gathering metrics for the queue manager
|
// StopMetricsGathering stops gathering metrics for the queue manager
|
||||||
func StopMetricsGathering() {
|
func StopMetricsGathering(log *logger.Logger) {
|
||||||
|
|
||||||
if metricsEnabled {
|
if metricsEnabled {
|
||||||
|
|
||||||
@@ -101,6 +102,9 @@ func StopMetricsGathering() {
|
|||||||
// Shutdown HTTP server
|
// Shutdown HTTP server
|
||||||
timeout, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
timeout, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
metricsServer.Shutdown(timeout)
|
err := metricsServer.Shutdown(timeout)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to shutdown metrics server: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ func processMetrics(log *logger.Logger, qmName string) {
|
|||||||
firstConnect = false
|
firstConnect = false
|
||||||
startChannel <- true
|
startChannel <- true
|
||||||
}
|
}
|
||||||
|
// #nosec G104
|
||||||
metrics, _ = initialiseMetrics(log)
|
metrics, _ = initialiseMetrics(log)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
29
manifests/dockerhub/manifest-9.1.1.yaml
Normal file
29
manifests/dockerhub/manifest-9.1.1.yaml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# © 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.
|
||||||
|
|
||||||
|
image: ibmcom/mq:9.1.1.0
|
||||||
|
manifests:
|
||||||
|
- image: ibmcom/mq:9.1.1.0-x86_64
|
||||||
|
platform:
|
||||||
|
architecture: amd64
|
||||||
|
os: linux
|
||||||
|
- image: ibmcom/mq:9.1.1.0-ppc64le
|
||||||
|
platform:
|
||||||
|
architecture: ppc64le
|
||||||
|
os: linux
|
||||||
|
- image: ibmcom/mq:9.1.1.0-s390x
|
||||||
|
platform:
|
||||||
|
architecture: s390x
|
||||||
|
os: linux
|
||||||
|
|
||||||
@@ -14,15 +14,15 @@
|
|||||||
|
|
||||||
image: ibmcom/mq:9
|
image: ibmcom/mq:9
|
||||||
manifests:
|
manifests:
|
||||||
- image: ibmcom/mq:9.1.0.0-x86_64
|
- image: ibmcom/mq:9.1.1.0-x86_64
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: linux
|
os: linux
|
||||||
- image: ibmcom/mq:9.1.0.0-ppc64le
|
- image: ibmcom/mq:9.1.1.0-ppc64le
|
||||||
platform:
|
platform:
|
||||||
architecture: ppc64le
|
architecture: ppc64le
|
||||||
os: linux
|
os: linux
|
||||||
- image: ibmcom/mq:9.1.0.0-s390x
|
- image: ibmcom/mq:9.1.1.0-s390x
|
||||||
platform:
|
platform:
|
||||||
architecture: s390x
|
architecture: s390x
|
||||||
os: linux
|
os: linux
|
||||||
|
|||||||
@@ -14,15 +14,15 @@
|
|||||||
|
|
||||||
image: ibmcom/mq:latest
|
image: ibmcom/mq:latest
|
||||||
manifests:
|
manifests:
|
||||||
- image: ibmcom/mq:9.1.0.0-x86_64
|
- image: ibmcom/mq:9.1.1.0-x86_64
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: linux
|
os: linux
|
||||||
- image: ibmcom/mq:9.1.0.0-ppc64le
|
- image: ibmcom/mq:9.1.1.0-ppc64le
|
||||||
platform:
|
platform:
|
||||||
architecture: ppc64le
|
architecture: ppc64le
|
||||||
os: linux
|
os: linux
|
||||||
- image: ibmcom/mq:9.1.0.0-s390x
|
- image: ibmcom/mq:9.1.1.0-s390x
|
||||||
platform:
|
platform:
|
||||||
architecture: s390x
|
architecture: s390x
|
||||||
os: linux
|
os: linux
|
||||||
|
|||||||
29
manifests/dockerstore/manifest-9.1.1.yaml
Normal file
29
manifests/dockerstore/manifest-9.1.1.yaml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# © 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.
|
||||||
|
|
||||||
|
image: ibmcorp/mqadvanced-server-dev:9.1.1.0
|
||||||
|
manifests:
|
||||||
|
- image: ibmcorp/mqadvanced-server-dev:9.1.1.0-x86_64
|
||||||
|
platform:
|
||||||
|
architecture: amd64
|
||||||
|
os: linux
|
||||||
|
- image: ibmcorp/mqadvanced-server-dev:9.1.1.0-ppc64le
|
||||||
|
platform:
|
||||||
|
architecture: ppc64le
|
||||||
|
os: linux
|
||||||
|
- image: ibmcorp/mqadvanced-server-dev:9.1.1.0-s390x
|
||||||
|
platform:
|
||||||
|
architecture: s390x
|
||||||
|
os: linux
|
||||||
|
|
||||||
47
mq-advanced-server-rhel/go-build.sh
Executable file
47
mq-advanced-server-rhel/go-build.sh
Executable file
@@ -0,0 +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
|
||||||
|
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/...
|
||||||
45
mq-advanced-server-rhel/go-buildah.sh
Executable file
45
mq-advanced-server-rhel/go-buildah.sh
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
# Run the Go build script inside the Go container, mounting the source
|
||||||
|
# directory in
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "Usage: $0 TAG DevModeFlag"
|
||||||
|
exit 20
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$#" -ne 2 ]; then
|
||||||
|
echo "ERROR: Invalid number of parameters"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly tag=$1
|
||||||
|
readonly dev=$2
|
||||||
|
|
||||||
|
IMAGE_REVISION=${IMAGE_REVISION:="Not Applicable"}
|
||||||
|
IMAGE_SOURCE=${IMAGE_SOURCE:="Not Applicable"}
|
||||||
|
|
||||||
|
podman run \
|
||||||
|
--volume ${PWD}:/go/src/github.com/ibm-messaging/mq-container/ \
|
||||||
|
--env GOPATH=/go \
|
||||||
|
--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"
|
||||||
81
mq-advanced-server-rhel/install-mq-rhel.sh
Executable file
81
mq-advanced-server-rhel/install-mq-rhel.sh
Executable file
@@ -0,0 +1,81 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "Usage: $0 MQContainer MountLocation ARCHIVENAME PACKAGES"
|
||||||
|
exit 20
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$#" -ne 4 ]; then
|
||||||
|
echo "ERROR: Invalid number of parameters"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly ctr_mq=$1
|
||||||
|
readonly mnt_mq=$2
|
||||||
|
readonly archive=$3
|
||||||
|
readonly mq_packages=$4
|
||||||
|
readonly dir_extract=/tmp/extract
|
||||||
|
|
||||||
|
if [ ! -d ${dir_extract}/MQServer ]; then
|
||||||
|
mkdir -p ${dir_extract}
|
||||||
|
echo Extracting $archive
|
||||||
|
tar -zxf $archive -C ${dir_extract}
|
||||||
|
echo Extracting finished
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If MQ_PACKAGES isn't specifically set, then choose a valid set of defaults
|
||||||
|
|
||||||
|
|
||||||
|
# Accept the MQ license
|
||||||
|
buildah run --volume ${dir_extract}:/mnt/mq-download $ctr_mq -- /mnt/mq-download/MQServer/mqlicense.sh -text_only -accept
|
||||||
|
|
||||||
|
buildah run --volume ${dir_extract}:/mnt/mq-download $ctr_mq -- bash -c "cd /mnt/mq-download/MQServer && rpm -ivh $mq_packages"
|
||||||
|
|
||||||
|
rm -rf ${dir_extract}/MQServer
|
||||||
|
|
||||||
|
# Remove 32-bit libraries from 64-bit container
|
||||||
|
find $mnt_mq/opt/mqm $mnt_mq/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 $mnt_mq/opt/mqm -name '*.tar.gz' -delete
|
||||||
|
|
||||||
|
# Recommended: Set the default MQ installation (makes the MQ commands available on the PATH)
|
||||||
|
buildah run $ctr_mq -- /opt/mqm/bin/setmqinst -p /opt/mqm -i
|
||||||
|
|
||||||
|
mkdir -p $mnt_mq/run/runmqserver
|
||||||
|
chown 888:888 $mnt_mq/run/runmqserver
|
||||||
|
|
||||||
|
# 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 a symlink for /var/mqm -> /mnt/mqm/data
|
||||||
|
buildah run $ctr_mq -- ln -s /mnt/mqm/data /var/mqm
|
||||||
|
|
||||||
|
# Optional: Set these values for the IBM Cloud Vulnerability Report
|
||||||
|
sed -i 's/PASS_MAX_DAYS\t99999/PASS_MAX_DAYS\t90/' $mnt_mq/etc/login.defs
|
||||||
|
sed -i 's/PASS_MIN_DAYS\t0/PASS_MIN_DAYS\t1/' $mnt_mq/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/' $mnt_mq/etc/pam.d/password-auth
|
||||||
|
|
||||||
|
buildah run $ctr_mq -- cp -rs /opt/mqm/licenses/ /
|
||||||
141
mq-advanced-server-rhel/mq-buildah.sh
Executable file
141
mq-advanced-server-rhel/mq-buildah.sh
Executable file
@@ -0,0 +1,141 @@
|
|||||||
|
#!/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
|
||||||
|
# Usage
|
||||||
|
# mq-buildah.sh ARCHIVEFILE PACKAGES
|
||||||
|
|
||||||
|
set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "Usage: $0 ARCHIVENAME PACKAGES TAG VERSION MQDevFlag"
|
||||||
|
exit 20
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$#" -ne 5 ]; then
|
||||||
|
echo "ERROR: Invalid number of parameters"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Setup MQ server working container
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
readonly ctr_mq=$(buildah from rhel7)
|
||||||
|
if [ -z "$ctr_mq" ]
|
||||||
|
then
|
||||||
|
echo "ERROR: ctr_mq is empty. Check above output for errors"
|
||||||
|
exit 50
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly mnt_mq=$(buildah mount $ctr_mq)
|
||||||
|
if [ -z "$mnt_mq" ]
|
||||||
|
then
|
||||||
|
echo "ERROR: mnt_mq is empty. Check above output for errors"
|
||||||
|
exit 50
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly archive=downloads/$1
|
||||||
|
readonly packages=$2
|
||||||
|
readonly tag=$3
|
||||||
|
readonly version=$4
|
||||||
|
readonly mqdev=$5
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Install MQ server
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
groupadd --root ${mnt_mq} --system --gid 888 mqm
|
||||||
|
useradd --root ${mnt_mq} --system --uid 888 --gid mqm mqm
|
||||||
|
usermod --root ${mnt_mq} -aG root mqm
|
||||||
|
usermod --root ${mnt_mq} -aG mqm root
|
||||||
|
|
||||||
|
# Install the packages required by MQ
|
||||||
|
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 \
|
||||||
|
file \
|
||||||
|
findutils \
|
||||||
|
gawk \
|
||||||
|
glibc-common \
|
||||||
|
grep \
|
||||||
|
passwd \
|
||||||
|
procps-ng \
|
||||||
|
sed \
|
||||||
|
tar \
|
||||||
|
util-linux
|
||||||
|
|
||||||
|
# Clean up cached files
|
||||||
|
buildah run $ctr_mq -- yum clean all
|
||||||
|
rm -rf ${mnt_mq}/var/cache/yum/*
|
||||||
|
|
||||||
|
# Install MQ server packages into the MQ builder image
|
||||||
|
./mq-advanced-server-rhel/install-mq-rhel.sh ${ctr_mq} "${mnt_mq}" "${archive}" "${packages}"
|
||||||
|
|
||||||
|
# Create the directory for MQ configuration files
|
||||||
|
mkdir -p ${mnt_mq}/etc/mqm
|
||||||
|
chown 888:888 ${mnt_mq}/etc/mqm
|
||||||
|
|
||||||
|
# Install the Go binaries into the image
|
||||||
|
install --mode 0750 --owner 888 --group 888 ./build/runmqserver ${mnt_mq}/usr/local/bin/
|
||||||
|
install --mode 6750 --owner 888 --group 888 ./build/chk* ${mnt_mq}/usr/local/bin/
|
||||||
|
install --mode 0750 --owner 888 --group 888 ./NOTICES.txt ${mnt_mq}/opt/mqm/licenses/notices-container.txt
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Final Buildah commands
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
if [ "$mqdev" = "TRUE" ]; then
|
||||||
|
OSTAG="mq messaging developer"
|
||||||
|
DISNAME="IBM MQ Advanced Server Developer Edition"
|
||||||
|
PID="98102d16795c4263ad9ca075190a2d4d"
|
||||||
|
else
|
||||||
|
OSTAG="mq messaging"
|
||||||
|
DISNAME="IBM MQ Advanced Server"
|
||||||
|
PID="4486e8c4cc9146fd9b3ce1f14a2dfc5b"
|
||||||
|
fi
|
||||||
|
|
||||||
|
buildah config \
|
||||||
|
--port 1414/tcp \
|
||||||
|
--port 9157/tcp \
|
||||||
|
--os linux \
|
||||||
|
--label architecture=x86_64 \
|
||||||
|
--label io.openshift.tags="$OSTAG" \
|
||||||
|
--label io.k8s.display-name="$DISNAME" \
|
||||||
|
--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="${tag%:*}" \
|
||||||
|
--label vendor="IBM" \
|
||||||
|
--label version="$version" \
|
||||||
|
--label release="1" \
|
||||||
|
--label run="docker run -d -e LICENSE=accept --name ibm-mq ${tag%:*}" \
|
||||||
|
--label summary="$DISNAME" \
|
||||||
|
--label 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 IBM_PRODUCT_ID="$PID" \
|
||||||
|
--label IBM_PRODUCT_NAME="$DISNAME" \
|
||||||
|
--label IBM_PRODUCT_VERSION="$version" \
|
||||||
|
--env AMQ_ADDITIONAL_JSON_LOG=1 \
|
||||||
|
--env LANG=en_US.UTF-8 \
|
||||||
|
--env LOG_FORMAT=basic \
|
||||||
|
--entrypoint runmqserver \
|
||||||
|
--user root \
|
||||||
|
$ctr_mq
|
||||||
|
buildah unmount $ctr_mq
|
||||||
|
buildah commit $ctr_mq $tag
|
||||||
|
|
||||||
|
buildah rm $ctr_mq
|
||||||
76
mq-advanced-server-rhel/mq-golang-sdk-buildah.sh
Executable file
76
mq-advanced-server-rhel/mq-golang-sdk-buildah.sh
Executable file
@@ -0,0 +1,76 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "Usage: $0 ARCHIVENAME TAG"
|
||||||
|
exit 20
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$#" -ne 2 ]; then
|
||||||
|
echo "ERROR: Invalid number of parameters"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly mq_archive=downloads/$1
|
||||||
|
readonly tag=$2
|
||||||
|
# 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_mq=$(buildah from rhel7)
|
||||||
|
if [ -z "$ctr_mq" ]
|
||||||
|
then
|
||||||
|
echo "ERROR: ctr_mq is empty. Check above output for errors"
|
||||||
|
exit 50
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly mnt_mq=$(buildah mount $ctr_mq)
|
||||||
|
if [ -z "$mnt_mq" ]
|
||||||
|
then
|
||||||
|
echo "ERROR: mnt_mq is empty. Check above output for errors"
|
||||||
|
exit 50
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add mqm user
|
||||||
|
sudo groupadd --root $mnt_mq --system --gid 888 mqm
|
||||||
|
sudo useradd --root $mnt_mq --system --uid 888 --gid mqm mqm
|
||||||
|
sudo usermod --root $mnt_mq -aG root mqm
|
||||||
|
sudo usermod --root $mnt_mq -aG mqm root
|
||||||
|
|
||||||
|
# Enable Yum repository for "optional" RPMs, which is needed for "golang"
|
||||||
|
buildah run ${ctr_mq} -- yum-config-manager --enable rhel-7-server-optional-rpms
|
||||||
|
# Install Go compiler
|
||||||
|
buildah run ${ctr_mq} -- yum install -y golang git gcc
|
||||||
|
|
||||||
|
# Install the MQ SDK into the Go builder image
|
||||||
|
./mq-advanced-server-rhel/install-mq-rhel.sh ${ctr_mq} "${mnt_mq}" "${mq_archive}" "MQSeriesRuntime-*.rpm MQSeriesSDK-*.rpm MQSeriesSamples*.rpm"
|
||||||
|
# Clean up Yum files
|
||||||
|
buildah run ${ctr_mq} -- yum clean all --releasever 7
|
||||||
|
rm -rf ${mnt_mq}/var/cache/yum/*
|
||||||
|
buildah unmount ${ctr_mq}
|
||||||
|
# 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_mq}
|
||||||
|
buildah commit ${ctr_mq} ${tag}
|
||||||
|
|
||||||
|
buildah rm ${ctr_mq}
|
||||||
113
mq-advanced-server-rhel/mqdev-buildah.sh
Executable file
113
mq-advanced-server-rhel/mqdev-buildah.sh
Executable file
@@ -0,0 +1,113 @@
|
|||||||
|
#!/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
|
||||||
|
# Usage
|
||||||
|
# mq-buildah.sh ARCHIVEFILE PACKAGES
|
||||||
|
|
||||||
|
set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "Usage: $0 BASETAG TAG VERSION"
|
||||||
|
exit 20
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$#" -ne 3 ]; then
|
||||||
|
echo "ERROR: Invalid number of parameters"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# 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 basetag=$1
|
||||||
|
readonly ctr_mq=$(buildah from $basetag)
|
||||||
|
if [ -z "$ctr_mq" ]
|
||||||
|
then
|
||||||
|
echo "ERROR: ctr_mq is empty. Check above output for errors"
|
||||||
|
exit 50
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly mnt_mq=$(buildah mount $ctr_mq)
|
||||||
|
if [ -z "$mnt_mq" ]
|
||||||
|
then
|
||||||
|
echo "ERROR: mnt_mq is empty. Check above output for errors"
|
||||||
|
exit 50
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly tag=$2
|
||||||
|
readonly version=$3
|
||||||
|
|
||||||
|
|
||||||
|
useradd --root $mnt_mq --gid mqm admin
|
||||||
|
groupadd --root $mnt_mq --system mqclient
|
||||||
|
useradd --root $mnt_mq --gid mqclient app
|
||||||
|
|
||||||
|
buildah run $ctr_mq -- id admin
|
||||||
|
buildah run $ctr_mq -- sh -c "echo admin:passw0rd | chpasswd"
|
||||||
|
|
||||||
|
mkdir -p $mnt_mq/run/runmqdevserver
|
||||||
|
chown 888:888 $mnt_mq/run/runmqdevserver
|
||||||
|
|
||||||
|
# Copy runmqdevserver program
|
||||||
|
install --mode 0750 --owner 888 --group 888 ./build/runmqdevserver ${mnt_mq}/usr/local/bin/
|
||||||
|
|
||||||
|
# Copy template files
|
||||||
|
cp incubating/mqadvanced-server-dev/*.tpl ${mnt_mq}/etc/mqm/
|
||||||
|
|
||||||
|
# Copy web XML files for default developer configuration
|
||||||
|
cp -R incubating/mqadvanced-server-dev/web ${mnt_mq}/etc/mqm/web
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Final Buildah commands
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
buildah config \
|
||||||
|
--port 1414/tcp \
|
||||||
|
--port 9157/tcp \
|
||||||
|
--port 9443/tcp \
|
||||||
|
--os linux \
|
||||||
|
--label architecture=x86_64 \
|
||||||
|
--label io.openshift.tags="mq messaging developer" \
|
||||||
|
--label io.k8s.display-name="IBM MQ Advanced Server Developer Edition" \
|
||||||
|
--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="${tag%:*}" \
|
||||||
|
--label vendor="IBM" \
|
||||||
|
--label version="$version" \
|
||||||
|
--label release="1" \
|
||||||
|
--label run="docker run -d -e LICENSE=accept --name ibm-mq-dev ${tag%:*}" \
|
||||||
|
--label summary="IBM MQ Advanced Server Developer Edition" \
|
||||||
|
--label 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 IBM_PRODUCT_ID="98102d16795c4263ad9ca075190a2d4d" \
|
||||||
|
--label IBM_PRODUCT_NAME="IBM MQ Advanced Server Developer Edition" \
|
||||||
|
--label IBM_PRODUCT_VERSION="$version" \
|
||||||
|
--env AMQ_ADDITIONAL_JSON_LOG=1 \
|
||||||
|
--env LANG=en_US.UTF-8 \
|
||||||
|
--env LOG_FORMAT=basic \
|
||||||
|
--env MQ_ADMIN_PASSWORD=passw0rd \
|
||||||
|
--env MQ_DEV=true \
|
||||||
|
--entrypoint runmqdevserver \
|
||||||
|
--user root \
|
||||||
|
$ctr_mq
|
||||||
|
buildah unmount $ctr_mq
|
||||||
|
buildah commit $ctr_mq $tag
|
||||||
|
|
||||||
|
buildah rm $ctr_mq
|
||||||
@@ -37,10 +37,11 @@ func TestDevGoldenPath(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
qm := "qm1"
|
||||||
containerConfig := container.Config{
|
containerConfig := container.Config{
|
||||||
Env: []string{
|
Env: []string{
|
||||||
"LICENSE=accept",
|
"LICENSE=accept",
|
||||||
"MQ_QMGR_NAME=qm1",
|
"MQ_QMGR_NAME=" + qm,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
id := runContainerWithPorts(t, cli, &containerConfig, []int{9443})
|
id := runContainerWithPorts(t, cli, &containerConfig, []int{9443})
|
||||||
@@ -49,7 +50,13 @@ func TestDevGoldenPath(t *testing.T) {
|
|||||||
waitForWebReady(t, cli, id, insecureTLSConfig)
|
waitForWebReady(t, cli, id, insecureTLSConfig)
|
||||||
t.Run("JMS", func(t *testing.T) {
|
t.Run("JMS", func(t *testing.T) {
|
||||||
// Run the JMS tests, with no password specified
|
// Run the JMS tests, with no password specified
|
||||||
runJMSTests(t, cli, id, false, "app", "")
|
runJMSTests(t, cli, id, false, "app", defaultAppPasswordOS)
|
||||||
|
})
|
||||||
|
t.Run("REST admin", func(t *testing.T) {
|
||||||
|
testRESTAdmin(t, cli, id, insecureTLSConfig)
|
||||||
|
})
|
||||||
|
t.Run("REST messaging", func(t *testing.T) {
|
||||||
|
testRESTMessaging(t, cli, id, insecureTLSConfig, qm, "app", defaultAppPasswordWeb)
|
||||||
})
|
})
|
||||||
// Stop the container cleanly
|
// Stop the container cleanly
|
||||||
stopContainer(t, cli, id)
|
stopContainer(t, cli, id)
|
||||||
@@ -63,12 +70,15 @@ func TestDevSecure(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
const tlsPassPhrase string = "passw0rd"
|
const tlsPassPhrase string = "passw0rd"
|
||||||
|
qm := "qm1"
|
||||||
|
appPassword := "differentPassw0rd"
|
||||||
containerConfig := container.Config{
|
containerConfig := container.Config{
|
||||||
Env: []string{
|
Env: []string{
|
||||||
"LICENSE=accept",
|
"LICENSE=accept",
|
||||||
"MQ_QMGR_NAME=qm1",
|
"MQ_QMGR_NAME=" + qm,
|
||||||
"MQ_APP_PASSWORD=" + devAppPassword,
|
"MQ_APP_PASSWORD=" + appPassword,
|
||||||
"MQ_TLS_KEYSTORE=/var/tls/server.p12",
|
"MQ_TLS_KEYSTORE=/var/tls/server.p12",
|
||||||
"MQ_TLS_PASSPHRASE=" + tlsPassPhrase,
|
"MQ_TLS_PASSPHRASE=" + tlsPassPhrase,
|
||||||
"DEBUG=1",
|
"DEBUG=1",
|
||||||
@@ -100,7 +110,17 @@ func TestDevSecure(t *testing.T) {
|
|||||||
waitForReady(t, cli, ctr.ID)
|
waitForReady(t, cli, ctr.ID)
|
||||||
cert := filepath.Join(tlsDir(t, true), "server.crt")
|
cert := filepath.Join(tlsDir(t, true), "server.crt")
|
||||||
waitForWebReady(t, cli, ctr.ID, createTLSConfig(t, cert, tlsPassPhrase))
|
waitForWebReady(t, cli, ctr.ID, createTLSConfig(t, cert, tlsPassPhrase))
|
||||||
runJMSTests(t, cli, ctr.ID, true, "app", devAppPassword)
|
|
||||||
|
t.Run("JMS", func(t *testing.T) {
|
||||||
|
runJMSTests(t, cli, ctr.ID, true, "app", appPassword)
|
||||||
|
})
|
||||||
|
t.Run("REST admin", func(t *testing.T) {
|
||||||
|
testRESTAdmin(t, cli, ctr.ID, insecureTLSConfig)
|
||||||
|
})
|
||||||
|
t.Run("REST messaging", func(t *testing.T) {
|
||||||
|
testRESTMessaging(t, cli, ctr.ID, insecureTLSConfig, qm, "app", appPassword)
|
||||||
|
})
|
||||||
|
|
||||||
// Stop the container cleanly
|
// Stop the container cleanly
|
||||||
stopContainer(t, cli, ctr.ID)
|
stopContainer(t, cli, ctr.ID)
|
||||||
}
|
}
|
||||||
@@ -129,7 +149,7 @@ func TestDevWebDisabled(t *testing.T) {
|
|||||||
})
|
})
|
||||||
t.Run("JMS", func(t *testing.T) {
|
t.Run("JMS", func(t *testing.T) {
|
||||||
// Run the JMS tests, with no password specified
|
// Run the JMS tests, with no password specified
|
||||||
runJMSTests(t, cli, id, false, "app", "")
|
runJMSTests(t, cli, id, false, "app", defaultAppPasswordOS)
|
||||||
})
|
})
|
||||||
// Stop the container cleanly
|
// Stop the container cleanly
|
||||||
stopContainer(t, cli, id)
|
stopContainer(t, cli, id)
|
||||||
|
|||||||
@@ -18,12 +18,15 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -34,8 +37,9 @@ import (
|
|||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
const devAdminPassword string = "passw0rd"
|
const defaultAdminPassword string = "passw0rd"
|
||||||
const devAppPassword string = "passw0rd"
|
const defaultAppPasswordOS string = ""
|
||||||
|
const defaultAppPasswordWeb string = "passw0rd"
|
||||||
|
|
||||||
// Disable TLS verification (server uses a self-signed certificate by default,
|
// Disable TLS verification (server uses a self-signed certificate by default,
|
||||||
// so verification isn't useful anyway)
|
// so verification isn't useful anyway)
|
||||||
@@ -58,7 +62,7 @@ func waitForWebReady(t *testing.T, cli *client.Client, ID string, tlsConfig *tls
|
|||||||
select {
|
select {
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(1 * time.Second):
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
req.SetBasicAuth("admin", devAdminPassword)
|
req.SetBasicAuth("admin", defaultAdminPassword)
|
||||||
resp, err := httpClient.Do(req.WithContext(ctx))
|
resp, err := httpClient.Do(req.WithContext(ctx))
|
||||||
if err == nil && resp.StatusCode == http.StatusOK {
|
if err == nil && resp.StatusCode == http.StatusOK {
|
||||||
t.Log("MQ web server is ready")
|
t.Log("MQ web server is ready")
|
||||||
@@ -83,6 +87,7 @@ func runJMSTests(t *testing.T, cli *client.Client, ID string, tls bool, user, pa
|
|||||||
"MQ_PORT_1414_TCP_ADDR=" + getIPAddress(t, cli, ID),
|
"MQ_PORT_1414_TCP_ADDR=" + getIPAddress(t, cli, ID),
|
||||||
"MQ_USERNAME=" + user,
|
"MQ_USERNAME=" + user,
|
||||||
"MQ_CHANNEL=DEV.APP.SVRCONN",
|
"MQ_CHANNEL=DEV.APP.SVRCONN",
|
||||||
|
"IBMJRE=" + os.Getenv("IBMJRE"),
|
||||||
},
|
},
|
||||||
Image: imageNameDevJMS(),
|
Image: imageNameDevJMS(),
|
||||||
}
|
}
|
||||||
@@ -140,17 +145,16 @@ func createTLSConfig(t *testing.T, certFile, password string) *tls.Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testREST(t *testing.T, cli *client.Client, ID string, tlsConfig *tls.Config) {
|
func testRESTAdmin(t *testing.T, cli *client.Client, ID string, tlsConfig *tls.Config) {
|
||||||
httpClient := http.Client{
|
httpClient := http.Client{
|
||||||
Timeout: time.Duration(30 * time.Second),
|
Timeout: time.Duration(30 * time.Second),
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
TLSClientConfig: tlsConfig,
|
TLSClientConfig: tlsConfig,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/admin/installation", getPort(t, cli, ID, 9443))
|
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/admin/installation", getPort(t, cli, ID, 9443))
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
req.SetBasicAuth("admin", devAdminPassword)
|
req.SetBasicAuth("admin", defaultAdminPassword)
|
||||||
resp, err := httpClient.Do(req)
|
resp, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -159,3 +163,70 @@ func testREST(t *testing.T, cli *client.Client, ID string, tlsConfig *tls.Config
|
|||||||
t.Errorf("Expected HTTP status code %v from 'GET installation'; got %v", http.StatusOK, resp.StatusCode)
|
t.Errorf("Expected HTTP status code %v from 'GET installation'; got %v", http.StatusOK, resp.StatusCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// curl -i -k https://localhost:1234/ibmmq/rest/v1/messaging/qmgr/qm1/queue/DEV.QUEUE.1/message -X POST -u app -H “ibm-mq-rest-csrf-token: N/A” -H “Content-Type: text/plain;charset=utf-8" -d “Hello World”
|
||||||
|
|
||||||
|
func logHTTPRequest(t *testing.T, req *http.Request) {
|
||||||
|
d, err := httputil.DumpRequestOut(req, true)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
t.Logf("HTTP request: %v", string(d))
|
||||||
|
}
|
||||||
|
|
||||||
|
func logHTTPResponse(t *testing.T, resp *http.Response) {
|
||||||
|
d, err := httputil.DumpResponse(resp, true)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
t.Logf("HTTP response: %v", string(d))
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRESTMessaging(t *testing.T, cli *client.Client, ID string, tlsConfig *tls.Config, qmName string, user string, password string) {
|
||||||
|
httpClient := http.Client{
|
||||||
|
Timeout: time.Duration(30 * time.Second),
|
||||||
|
Transport: &http.Transport{
|
||||||
|
TLSClientConfig: tlsConfig,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
q := "DEV.QUEUE.1"
|
||||||
|
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/messaging/qmgr/%s/queue/%s/message", getPort(t, cli, ID, 9443), qmName, q)
|
||||||
|
putMessage := []byte("Hello")
|
||||||
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(putMessage))
|
||||||
|
req.SetBasicAuth(user, password)
|
||||||
|
req.Header.Add("ibm-mq-rest-csrf-token", "n/a")
|
||||||
|
req.Header.Add("Content-Type", "text/plain;charset=utf-8")
|
||||||
|
logHTTPRequest(t, req)
|
||||||
|
resp, err := httpClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
logHTTPResponse(t, resp)
|
||||||
|
if resp.StatusCode != http.StatusCreated {
|
||||||
|
t.Errorf("Expected HTTP status code %v from 'POST to queue'; got %v", http.StatusOK, resp.StatusCode)
|
||||||
|
t.Logf("HTTP response: %+v", resp)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err = http.NewRequest("DELETE", url, nil)
|
||||||
|
req.Header.Add("ibm-mq-rest-csrf-token", "n/a")
|
||||||
|
req.SetBasicAuth(user, password)
|
||||||
|
logHTTPRequest(t, req)
|
||||||
|
resp, err = httpClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
logHTTPResponse(t, resp)
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
t.Errorf("Expected HTTP status code %v from 'DELETE from queue'; got %v", http.StatusOK, resp.StatusCode)
|
||||||
|
t.Logf("HTTP response: %+v", resp)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
gotMessage, err := ioutil.ReadAll(resp.Body)
|
||||||
|
//gotMessage := string(b)
|
||||||
|
if string(gotMessage) != string(putMessage) {
|
||||||
|
t.Errorf("Expected payload to be \"%s\"; got \"%s\"", putMessage, gotMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -684,10 +684,11 @@ func TestVersioning(t *testing.T) {
|
|||||||
dataAr := strings.Split(line, " ")
|
dataAr := strings.Split(line, " ")
|
||||||
data := dataAr[len(dataAr)-1]
|
data := dataAr[len(dataAr)-1]
|
||||||
|
|
||||||
// Verify created
|
// Verify created is in a known timestamp format
|
||||||
_, err := time.Parse(time.RFC3339, data)
|
_, err := time.Parse(time.RFC3339, data)
|
||||||
if err != nil {
|
_, err2 := time.Parse("2006-01-02T15:04:05-0700", data)
|
||||||
t.Errorf("Failed to validate Image created (%v) - %v", data, err)
|
if err != nil && err2 != nil {
|
||||||
|
t.Errorf("Failed to validate Image created stamp (%v) - %v or %v", data, time.RFC3339, "2006-01-02T15:04:05-0700")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ RUN find /usr/src/mymaven
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# Application runtime (JRE only, no build environment)
|
# Application runtime (JRE only, no build environment)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
FROM ibmjava:sfj
|
FROM ibmjava:8-jre
|
||||||
COPY --from=builder /usr/src/mymaven/target/*.jar /opt/app/
|
COPY --from=builder /usr/src/mymaven/target/*.jar /opt/app/
|
||||||
COPY --from=builder /usr/src/mymaven/target/lib/*.jar /opt/app/
|
COPY --from=builder /usr/src/mymaven/target/lib/*.jar /opt/app/
|
||||||
ENTRYPOINT ["java", "-classpath", "/opt/app/*", "org.junit.platform.console.ConsoleLauncher", "-p", "com.ibm.mqcontainer.test", "--details", "verbose"]
|
ENTRYPOINT ["java", "-classpath", "/opt/app/*", "org.junit.platform.console.ConsoleLauncher", "-p", "com.ibm.mqcontainer.test", "--details", "verbose"]
|
||||||
|
|||||||
77
test/messaging/buildah.sh
Executable file
77
test/messaging/buildah.sh
Executable file
@@ -0,0 +1,77 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# © 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.
|
||||||
|
|
||||||
|
set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Setup MQ JMS Test 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 rhel7)
|
||||||
|
readonly mnt_mq=$(buildah mount $ctr_mq)
|
||||||
|
readonly imagename=$1
|
||||||
|
|
||||||
|
buildah run $ctr_mq -- yum install -y \
|
||||||
|
java-1.7.0-openjdk-devel \
|
||||||
|
java \
|
||||||
|
which \
|
||||||
|
wget
|
||||||
|
|
||||||
|
buildah run $ctr_mq -- sh -c "cd /tmp && wget http://mirror.olnevhost.net/pub/apache/maven/binaries/apache-maven-3.2.2-bin.tar.gz"
|
||||||
|
tar xvf $mnt_mq/tmp/apache-maven-3.2.2-bin.tar.gz -C $mnt_mq/tmp/
|
||||||
|
|
||||||
|
mkdir -p $mnt_mq/usr/src/mymaven
|
||||||
|
cp pom.xml $mnt_mq/usr/src/mymaven/
|
||||||
|
cp -R src $mnt_mq/usr/src/mymaven/src
|
||||||
|
|
||||||
|
buildah run $ctr_mq -- sh -c "cd /usr/src/mymaven && export M2_HOME=/tmp/apache-maven-3.2.2 && export M2=\$M2_HOME/bin && export PATH=\$M2:\$PATH && mvn --version && mvn dependency:go-offline install && mvn --offline install"
|
||||||
|
|
||||||
|
mkdir -p $mnt_mq/opt/app
|
||||||
|
|
||||||
|
cp $mnt_mq/usr/src/mymaven/target/*.jar $mnt_mq/opt/app/
|
||||||
|
cp $mnt_mq/usr/src/mymaven/target/lib/*.jar $mnt_mq/opt/app/
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Post install tidy up
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
rm -rf $mnt_mq/tmp/*
|
||||||
|
rm -rf $mnt_mq/usr/src/mymaven
|
||||||
|
|
||||||
|
# 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
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
buildah config \
|
||||||
|
--os linux \
|
||||||
|
--label architecture=x86_64 \
|
||||||
|
--label name="${imagename%:*}" \
|
||||||
|
--entrypoint '["java", "-classpath", "/opt/app/*", "org.junit.platform.console.ConsoleLauncher", "-p", "com.ibm.mqcontainer.test", "--details", "verbose"]' \
|
||||||
|
$ctr_mq
|
||||||
|
buildah unmount $ctr_mq
|
||||||
|
buildah commit $ctr_mq $imagename
|
||||||
|
|
||||||
|
buildah rm $ctr_mq
|
||||||
@@ -73,6 +73,10 @@ class JMSTests {
|
|||||||
factory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
|
factory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
|
||||||
factory.setChannel(channel);
|
factory.setChannel(channel);
|
||||||
factory.setConnectionNameList(String.format("%s(1414)", addr));
|
factory.setConnectionNameList(String.format("%s(1414)", addr));
|
||||||
|
// If a password is set, make sure it gets sent to the queue manager for authentication
|
||||||
|
if (password != null) {
|
||||||
|
factory.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
|
||||||
|
}
|
||||||
// factory.setClientReconnectOptions(WMQConstants.WMQ_CLIENT_RECONNECT);
|
// factory.setClientReconnectOptions(WMQConstants.WMQ_CLIENT_RECONNECT);
|
||||||
if (TRUSTSTORE == null) {
|
if (TRUSTSTORE == null) {
|
||||||
LOGGER.info("Not using TLS");
|
LOGGER.info("Not using TLS");
|
||||||
@@ -81,8 +85,14 @@ class JMSTests {
|
|||||||
LOGGER.info(String.format("Using TLS. Trust store=%s", TRUSTSTORE));
|
LOGGER.info(String.format("Using TLS. Trust store=%s", TRUSTSTORE));
|
||||||
SSLSocketFactory ssl = createSSLSocketFactory();
|
SSLSocketFactory ssl = createSSLSocketFactory();
|
||||||
factory.setSSLSocketFactory(ssl);
|
factory.setSSLSocketFactory(ssl);
|
||||||
|
boolean ibmjre = System.getenv("IBMJRE").equals("true");
|
||||||
|
if (ibmjre){
|
||||||
|
System.setProperty("com.ibm.mq.cfg.useIBMCipherMappings", "true");
|
||||||
factory.setSSLCipherSuite("SSL_RSA_WITH_AES_128_CBC_SHA256");
|
factory.setSSLCipherSuite("SSL_RSA_WITH_AES_128_CBC_SHA256");
|
||||||
// LOGGER.info(Arrays.toString(ssl.getSupportedCipherSuites()));
|
} else {
|
||||||
|
System.setProperty("com.ibm.mq.cfg.useIBMCipherMappings", "false");
|
||||||
|
factory.setSSLCipherSuite("TLS_RSA_WITH_AES_128_CBC_SHA256");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Give up if unable to reconnect for 10 minutes
|
// Give up if unable to reconnect for 10 minutes
|
||||||
// factory.setClientReconnectTimeout(600);
|
// factory.setClientReconnectTimeout(600);
|
||||||
|
|||||||
Reference in New Issue
Block a user