-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·63 lines (56 loc) · 1.41 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
#!/usr/bin/env bash
#
# build.sh [-v VERSION] [-l LOCALE]
#
function printUsage() {
cat <<-EOE
build.sh [-v VERSION] [-l LOCALE] [-h]
description:
Build a Docker image of the specified version of Silverpeas.
The docker image will be tagged with the version of Silverpeas.
If no version is passed in the command line, then a Docker image will be
built for the version of Silverpeas specified in the Dockerfile.
with:
-h|--help Print this help.
-v VERSION The version of Silverpeas. By default the one specified in the
Dockerfile.
-l LOCALE The locale to use. By default en_US.UTF-8.
EOE
}
function die() {
echo "Error: $1"
exit 1
}
function checkNotEmpty() {
test "Z$1" != "Z" || die "Parameter is empty"
}
version=`grep 'ENV SILVERPEAS_VERSION' Dockerfile | cut -d '=' -f 2`
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h|--help)
printUsage
exit 0
;;
-v)
checkNotEmpty "$2"
version="$2"
git checkout ${version} &>/dev/null
shift # past argument
shift # past first value
;;
-l)
checkNotEmpty "$2"
locale="--build-arg DEFAULT_LOCALE=$2"
shift # past argument
shift # past first value
;;
*)
die "Unknown option: $1"
;;
esac
done
echo "Build a docker image for Silverpeas ${version}"
sleep 1
docker build -t ${locale} silverpeas:${version} .
git checkout master &> /dev/null