-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker_build_image.sh
executable file
·85 lines (76 loc) · 1.51 KB
/
docker_build_image.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -euo pipefail
function build() {
echo
echo "Building binary: ${GF}"
echo
if [[ -e ${GF} ]] ; then
echo
echo "Using existing binary: ${GF}"
echo
ls -l ${GF}
return
fi
CGO_ENABLED=0 go build -ldflags="-s -w"
if [[ ! -e ${GF} ]] ; then
echo
echo "Unable to build file: ${GF}"
echo "Build aborted"
echo
exit 1
else
echo
ls -l ${GF}
fi
}
function bundle() {
echo
echo "Generating file: ${SC}/${BUND}"
echo
cd ${SC}
curl -LOs https://raw.githubusercontent.com/curl/curl/master/scripts/mk-ca-bundle.pl
perl mk-ca-bundle.pl
if [[ ! -e ${BUND} ]] ; then
echo
echo "Unable to create file: ${BUND}"
echo "Build aborted"
echo
exit 1
else
rm -f certdata.txt mk-ca-bundle.pl
chmod 644 ${BUND}
echo
ls -l ${BUND}
cd -
fi
}
function image() {
echo
echo Creating Docker Image: ${IMG}
echo
sleep 1
docker build -t ${IMG} -f Dockerfile .
docker image ls ${IMG}
echo
echo
echo Now, use ${IMG} within the docker_start_gofwd.sh script,
echo which will need editing for your deployment.
echo
}
if [ $# -eq 0 ] ; then
echo give Version Tag on cmd line
echo example: v052.1
exit 1
fi
IMG=$1
BUND="ca-bundle.crt"
SC="ssl/certs/"
GF="gofwd"
#GOOS="linux"
#GOARCH="amd64"
if [[ ! -e ${SC} ]] ; then
mkdir -p -m 755 ${SC}
fi
build
bundle
image