-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbp.sh
executable file
·75 lines (59 loc) · 1.86 KB
/
bp.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
#!/bin/sh
### BEGIN ###
# Author: idevz
# Since: 2018/03/12
# Description: Build and push Docker image.
### END ###
set -e
BASE_DIR=$(dirname $(cd $(dirname "$0") && pwd -P)/$(basename "$0"))
. .building_versions_info.sh
DEFAULT_GOOS=linux
DEFAULT_GOARCH=amd64
GOLANG_VERSION=${GOLANG_VERSION=$DEFAULT_GOLANG_VERSION}
GOLANG_GOOS=${GOLANG_GOOS=$DEFAULT_GOOS}
GOLANG_GOARCH=${GOLANG_GOARCH=$DEFAULT_GOARCH}
IMAGE=golang:${GOLANG_VERSION}
NOTIC_PREFIX="\n - --- --- "
NOTIC_SUFFIX=" --- --- -\n "
xnotic() {
echo ${NOTIC_PREFIX}$1${NOTIC_SUFFIX}
}
################################################ Docker images Build Start ################################################
cross_build() {
ONE=$1
docker run --rm \
-v "${BASE_DIR}/${ONE}":/go/src/weibo-mesh/golang-use/${ONE} \
-w /go/src/weibo-mesh/golang-use/${ONE} \
-e CGO_ENABLED=0 \
-e GOARCH=${GOLANG_GOARCH} \
-e GOOS=${GOLANG_GOOS} \
${IMAGE} go build -a -installsuffix cgo -o weibo-mesh-${ONE} \
weibo-mesh/golang-use/${ONE}
xnotic "cross build done."
}
images_bp() {
ONE=$1
docker build -t weibocom/weibo-mesh-demo-${ONE}:${WEIBO_MESH_VERSION} ${BASE_DIR}/${ONE}
xnotic "docker build done."
if [ `uname` == "Darwin" ]; then
docker push weibocom/weibo-mesh-demo-${ONE}:${WEIBO_MESH_VERSION}
xnotic "docker push to public hub done."
fi
}
clean_image_building_tpms() {
ONE=$1
rm ${BASE_DIR}/${ONE}/weibo-mesh-${ONE}
xnotic "docker building tmps cleaned."
}
################################################ build images
build_docker_images() {
for one in client server;
do
cross_build $one
images_bp $one
clean_image_building_tpms $one
xnotic "build docker images done."
done
}
################################################ run
build_docker_images