-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·72 lines (60 loc) · 1.25 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
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
scriptPath=$(dirname "$(readlink -f "$0")")
cd ${scriptPath}/
function deactivate_env {
echo "Deactivating env variables ..."
unset SERVICE_VERSION
}
function display_help() {
echo "Build image for ove-ui"
echo
echo "usage: build.sh [option]..."
echo " --push Push the image"
echo " -v, --version The version of the service"
}
version=$(git describe --tags --exact-match 2> /dev/null)
if [ $? -ne 0 ]; then
version="latest"
fi
version="${version}-unstable"
pushImage=false
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h|--help)
display_help
exit 0
;;
-v|--version)
version="$2"
echo "Recognized user version = ${version}"
shift
;;
--push)
pushImage=true
;;
*)
echo "Unrecognised option: $key"
echo
display_help
exit 1
;;
esac
shift
done
export SERVICE_VERSION=${version}
trap deactivate_env EXIT SIGINT SIGTERM
echo "Building version = ${SERVICE_VERSION}"
npm run build:clean
if [ $? -ne 0 ]; then
# fail if the image build process failed
exit 1
fi
docker-compose build
if [ $? -ne 0 ]; then
# fail if the image build process failed
exit 1
fi
if [ "${pushImage}" = true ]; then
docker-compose push
fi