-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·61 lines (53 loc) · 1.01 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
58
59
60
#!/bin/sh
ALL="pendb penmm penfe penen penadm"
usage()
{
echo "Usage: build.sh [-p] (name)"
echo " name: ${ALL}"
exit -1
}
build_image()
{
(
name=$1
echo "==== Build ${name} ===="
if [ ! -d "${name}" ] ; then
echo "ERROR: $name doesn't exist."
return
fi
cd ${name} && \
if [ "`docker images ${name}:build -q`" ] ; then
docker rmi ${name}:build ;
fi && \
docker build -t ${name}:build --build-arg __NC=`date +%Y%m%d%H%M%S` .
)
}
push_image()
{
(
name=$1
tag=`grep ${name} latest-versions.txt | cut -d: -f2`
pubname=tanupoo/${name}:${tag}
echo "==== Push ${pubname} ===="
docker tag ${name}:build ${pubname} && \
docker push ${pubname}
)
}
#
# main
#
if [ "$1" = "-p" ] ; then
mode="push_image"
shift
targets=$*
else
mode="build_image"
targets=$*
fi
if [ -z "$targets" ] ; then
usage
fi
for t in ${targets}
do
$mode $t
done