-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·83 lines (69 loc) · 1.31 KB
/
build.sh
File metadata and controls
executable file
·83 lines (69 loc) · 1.31 KB
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
76
77
78
79
80
81
82
83
#!/bin/bash
#
# Build script for time2backup docker image
#
# go into current directory
cd "$(dirname "$0")" || exit 1
#
# Functions
#
# Print usage
print_help() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -v, --version VERSION Specify a version"
echo " -b, --branch stable|unstable Specify a branch (stable by default)"
echo " -h, --help Print this help"
}
#
# Main program
#
branch=stable
# get options
while [ $# -gt 0 ] ; do
case $1 in
-v|--version)
if [ -z "$2" ] ; then
print_help
exit 1
fi
version=$2
shift
;;
-b|--branch)
case $2 in
stable|unstable)
branch=$2
shift
;;
*)
print_help
exit 1
;;
esac
;;
-h|--help)
print_help
exit
;;
*)
break
;;
esac
shift
done
# prompt to choose version
if [ -z "$version" ] ; then
version=$(grep 'VERSION=' Dockerfile | head -1 | cut -d= -f2)
echo -n "Choose version: [$version] "
read version_user
if [ -n "$version_user" ] ; then
version=$version_user
fi
echo
fi
echo "Prepare Dockerfile..."
sed -i "s/BRANCH=.*/BRANCH=$branch/; s/VERSION=.*/VERSION=$version/" Dockerfile || exit
echo "Build image..."
docker pull "$(grep '^FROM ' Dockerfile | awk '{print $2}')" || exit
docker build -t time2backup/time2backup:$version . || exit