Skip to content

Commit 51271ee

Browse files
committed
Add an automated build
1 parent 199bcd8 commit 51271ee

File tree

6 files changed

+219
-0
lines changed

6 files changed

+219
-0
lines changed

Dockerfile-build-packages

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# © Copyright IBM Corporation 2018
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG BASE_IMAGE=mq-sdk:9.0.5.0-x86_64-ubuntu-16.04
16+
17+
FROM $BASE_IMAGE
18+
19+
ENV GO_VERSION=1.10
20+
21+
# Install the Go compiler and Git
22+
RUN export DEBIAN_FRONTEND=noninteractive \
23+
&& bash -c 'source /etc/os-release; \
24+
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME} main restricted" > /etc/apt/sources.list; \
25+
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME}-updates main restricted" >> /etc/apt/sources.list; \
26+
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME}-backports main restricted universe" >> /etc/apt/sources.list;' \
27+
&& apt-get update \
28+
&& apt-get install -y --no-install-recommends golang-${GO_VERSION} git ca-certificates \
29+
&& rm -rf /var/lib/apt/lists/*
30+
31+
ENV PATH="${PATH}:/usr/lib/go-${GO_VERSION}/bin:/go/bin" \
32+
CGO_CFLAGS="-I/opt/mqm/inc/" \
33+
CGO_LDFLAGS_ALLOW="-Wl,-rpath.*" \
34+
GOPATH="/go" \
35+
OUTPUT_DIR="${OUTPUT_DIR}"
36+
37+
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" "$GOPATH/pkg" \
38+
&& chmod -R 777 "$GOPATH" \
39+
&& mkdir -p "$GOPATH/src/github.com/ibm-messaging/mq-golang"
40+
41+
WORKDIR $GOPATH/src/github.com/ibm-messaging/mq-golang
42+
43+
COPY ./ibmmq ibmmq
44+
COPY ./mqmetric mqmetric
45+
46+
RUN go build ./ibmmq \
47+
&& go test ./ibmmq \
48+
&& go build ./mqmetric \
49+
&& go test ./mqmetric

Dockerfile-build-samples

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# © Copyright IBM Corporation 2018
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG BASE_IMAGE=mq-golang-build:9.0.5.0-x86_64-ubuntu-16.04
16+
17+
FROM $BASE_IMAGE
18+
19+
RUN mkdir -p "$GOPATH/src/github.com/ibm-messaging/mq-golang/samples"
20+
WORKDIR $GOPATH/src/github.com/ibm-messaging/mq-golang/samples
21+
22+
COPY ./samples/clientconn clientconn
23+
COPY ./samples/mqitest mqitest
24+
25+
RUN go install ./clientconn \
26+
&& go install ./mqitest

Makefile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# © Copyright IBM Corporation 2018
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
###############################################################################
16+
# Conditional variables - you can override the values of these variables from
17+
# the command line
18+
###############################################################################
19+
# BASE_IMAGE is the MQ SDK base image to use
20+
BASE_IMAGE ?= mq-sdk:9.0.5.0-x86_64-ubuntu-16.04
21+
# GO_IMAGE is the GOLANG image to use for building samples
22+
GO_IMAGE ?= golang:1.10
23+
# DOCKER is the Docker command to run
24+
DOCKER ?= docker
25+
# BUILD_IMAGE is the name of the image that will be produced while building packages
26+
BUILD_IMAGE ?= mq-golang-build:9.0.5.0-x86_64-ubuntu-16.04
27+
# SAMPLE_BUILD_IMAGE is the name of the image that will be produced while building samples
28+
SAMPLE_BUILD_IMAGE ?= mq-sample-build:9.0.5.0-x86_64-ubuntu-16.04
29+
30+
###############################################################################
31+
# Other variables
32+
###############################################################################
33+
34+
ifneq (,$(findstring Microsoft,$(shell uname -r)))
35+
PLATFORM=WINDOWS
36+
else
37+
PLATFORM=UNIX
38+
endif
39+
40+
###############################################################################
41+
# Build targets
42+
###############################################################################
43+
44+
# Build all packages when on unix
45+
.PHONY: all
46+
ifeq ("$(PLATFORM)", "WINDOWS")
47+
all: unsupported-message
48+
else
49+
all: build-packages-unix build-samples-unix
50+
endif
51+
52+
.PHONY: clean
53+
clean:
54+
$(DOCKER) rmi -f $(BUILD_IMAGE)
55+
$(DOCKER) rmi -f $(SAMPLE_BUILD_IMAGE)
56+
57+
.PHONY: build-packages-unix
58+
build-packages-unix:
59+
$(info $(SPACER)$(shell printf $(TITLE)"Building packages in build container"$(END)))
60+
$(call docker-build,$(BUILD_IMAGE),Dockerfile-build-packages,$(BASE_IMAGE))
61+
62+
.PHONY: build-samples-unix
63+
build-samples-unix: build-packages-unix
64+
$(info $(SPACER)$(shell printf $(TITLE)"Building samples in build container"$(END)))
65+
$(call docker-build,$(SAMPLE_BUILD_IMAGE),Dockerfile-build-samples,$(BUILD_IMAGE))
66+
67+
.PHONY: unsupported-message
68+
unsupported-message:
69+
$(info $(SPACER)$(shell printf $(TITLE)"This makefile can only be ran on UNIX platforms"$(END)))
70+
71+
define docker-build
72+
# Build the image first to compile the package/samples
73+
$(DOCKER) build -t $1 \
74+
-f $2 \
75+
--build-arg BASE_IMAGE=$3 \
76+
.
77+
endef
78+
79+
include formatting.mk

formatting.mk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
GREEN="\033[32m"
2+
RED="\033[31m"
3+
BLUE="\033[34m"
4+
PURPLE="\033[35m"
5+
AQUA="\033[36m"
6+
7+
END="\033[0m"
8+
9+
UNDERLINE="\033[4m"
10+
BOLD="\033[1m"
11+
12+
TITLE=$(BLUE)$(BOLD)$(UNDERLINE)
13+
14+
define SPACER
15+
16+
17+
endef

ibmmq/ibmmq_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
© Copyright IBM Corporation 2018
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
package ibmmq
17+
18+
import (
19+
"testing"
20+
)
21+
22+
func TestIBMMQ(t *testing.T) {
23+
// TODO
24+
}

mqmetric/mqmetric_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
© Copyright IBM Corporation 2018
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
package mqmetric
17+
18+
import (
19+
"testing"
20+
)
21+
22+
func TestMQMetric(t *testing.T) {
23+
// TODO
24+
}

0 commit comments

Comments
 (0)