-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.sh
executable file
·54 lines (41 loc) · 1022 Bytes
/
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
#!/bin/bash
# 例子
# sh build.sh 3-alpine 3.13-alpine 3.13.0-alpine
set -e
# 输入参数
tag=${1:-3}
# 版本
version=${tag/-*/}
# 版本标签
tagname=${tag/*-/}
# 对应目录
dir="$version/$tagname"
# 如果没标签,默认 jessie 版本
if [ "$version" = "$tagname" ]; then
dir="$version/jessie"
fi
# 判断目录是否存在
if [ ! -d $dir ]; then
echo "no such tag: $tag"
exit -1
fi
# 构建镜像
docker build -f $dir/Dockerfile -t toomee/alinode:$tag context
echo
echo "✨ toomee/alinode:$tag is done!"
echo
if [ $# -gt 1 ]; then
for ((i=2; i<=$#; i++)); do
echo "Create tag $tag -> ${!i}"
docker tag toomee/alinode:$tag toomee/alinode:${!i}
done
fi
echo
if [ "$version" = "$tagname" ]; then
docker images toomee/alinode:$tag*
else
docker images toomee/alinode:$version*-$tagname
fi
echo
docker run --rm toomee/alinode:$tag sh -c 'echo "alinode v$ALINODE_VERSION" && echo "node $(node -v)" && echo "npm v$(npm -v)" && echo "yarn v$(yarn -v)" && echo "pm2 v$(pm2 -v)"'
echo