forked from ibm-messaging/mq-metric-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildInDocker.sh
60 lines (51 loc) · 1.61 KB
/
buildInDocker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# © Copyright IBM Corporation 2019
#
# 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.
# Script to build the monitor agent programs from within a Docker container
export PATH="${PATH}:/usr/lib/go-${GOVERSION}/bin:/go/bin"
export CGO_CFLAGS="-I/opt/mqm/inc/"
export CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"
export GOCACHE=/tmp/.cache
# Which monitor programs are to be built. By default, build the complete set available.
# It can be overridden by setting the value on the "docker run" command with
# a "-e MONITORS=..." flag.
if [ -z "$MONITORS" ]
then
cd $GOPATH/src/$ORG/$REPO
MONITORS=`ls cmd`
fi
echo "Using compiler:"
go version
# And do the builds into the bin directory
cd $GOPATH
for m in $MONITORS
do
srcdir=src/$ORG/$REPO/cmd/$m
echo "Building $m"
if [ ! -z "$BUILD_EXTRA_INJECT" ]
then
BUILD_EXTRA_LDFLAGS="-ldflags"
fi
go build -o bin/$m $BUILD_EXTRA_LDFLAGS "$BUILD_EXTRA_INJECT" $srcdir/*.go
# Copy the supporting scripts into the output directory
if [ -r $srcdir/$m.sh ]
then
cp $srcdir/*.sh bin
chmod a+rx bin/*.sh
fi
if [ -r $srcdir/$m.mqsc ]
then
cp $srcdir/*.mqsc bin
fi
done