-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
57 lines (44 loc) · 1.16 KB
/
build.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
#!/bin/bash
export PROJECT_NAME=$1
export THREAD=$2
docker_names=('oauth-api' 'oauth-rpc-token-enhancer' 'oauth-rpc-token-store' \
'user-api' 'user-rpc-crud' 'user-rpc-info' 'user-rpc-vip' 'notification-api' \
'notification-rpc-crud' 'notification-rpc-info' 'mq-asynq-scheduler' 'mq-asynq-processor' \
'mq-nsq-consumer' 'question-api' 'question-rpc-crud' 'question-rpc-info' \
'comment-api' 'comment-rpc-crud' 'comment-rpc-info')
function docker_build() {
if [ "$1" -ef "" ]; then
return 0
fi
array=$(echo "$1" | tr '-' '\n')
path='./app/service'
for var in $array
do
path="${path}""/""${var}"
done
docker build -t "$PROJECT_NAME""_""$1" "${path}"
return 1
}
[ -e /tmp/fd1 ] || mkfifo /tmp/fd1
exec 3<>/tmp/fd1
rm -rf /tmp/fd1
for ((i=1;i<=THREAD;i++))
do
echo >&3
done
cd /www/site/"$PROJECT_NAME" || exit
remain_build=${#docker_names[@]}
echo "start building images, remain: ""${remain_build}"
for docker_name in ${docker_names[*]}
do
read -r -u3
{
docker_build "${docker_name}"
remain_build=$(expr "${remain_build}" - 1)
echo "build ""${docker_name}"" complete, remain: ""${remain_build}"
echo >&3
} &
done
wait
exec 3<&-
exec 3>&-