-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdockerbuild.sh
executable file
·61 lines (53 loc) · 1.06 KB
/
dockerbuild.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
#!/bin/bash
set -e
set -o pipefail
tag=latest
usage() {
cat <<EOF
Usage: $0 [OPTION]...
OPTION:
-h, --help print this text and exit.
-t, --tag=NAME image tag. default to latest.
-p, --push push image
EOF
}
get_tag() {
sed -n -E 's/^LABEL version="(.*)"/\1/p' ./Dockerfile
}
while [ $# -gt 0 ]; do
case "$1" in
-h | --help)
usage
shift
;;
-t | --tag)
tag="$2"
shift 2
;;
-p | --push)
PUSH=true
shift
;;
*)
echo >&2 "bad option: $"
exit 1
;;
esac
done
cd "$(dirname "$0")"
vtag="$(get_tag)"
image="docker.io/googletranslate/bbdown-web"
docker build -t "${image}:${tag}" .
echo "build ${image}:${tag}"
if [ -n "$vtag" ]; then
docker build -t "${image}:${vtag}" .
echo "build ${image}:${vtag}"
fi
if [ "${PUSH}" = true ]; then
docker push "${image}:${tag}"
echo "push ${image}:${tag}"
if [ -n "$tag" ]; then
docker push "${image}:${vtag}"
echo "push ${image}:${vtag}"
fi
fi