forked from LREN-CHUV/r-base-docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·97 lines (85 loc) · 2.04 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash -e
# Usage:
# ./build.sh [--all] [--R] [--java]
get_script_dir () {
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$( readlink "$SOURCE" )"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
cd -P "$( dirname "$SOURCE" )"
pwd
}
ROOT_DIR="$(get_script_dir)"
R_IMAGES="r-mip r-libs r-java r-database r-job r-interactive"
JAVA_IMAGES="java-base java-mip java-rapidminer scala-base"
R_BUILD=false
JAVA_BUILD=false
NARGS=-1; while [ "$#" -ne "$NARGS" ]; do NARGS=$#
case $1 in
"-h"|"--help")
echo "Ugage:"
echo "./build.sh [--all] [--R] [--java]"
exit 1;
break
;;
"--all")
R_IMAGES="r-base $R_IMAGES"
R_BUILD=true
JAVA_BUILD=true
break
;;
"--R"|"--r")
R_BUILD=true
break
;;
"--java")
JAVA_BUILD=true
break
;;
"")
if [[ $NARGS == 0 ]]; then
R_BUILD=true
JAVA_BUILD=true
fi
break
;;
*) echo invalid option;;
esac
done
if [ "$1" = "--all" ]; then
R_IMAGES="r-base $R_IMAGES"
else
echo "Skip building base images. Add --all parameter to build also those base images"
fi
if groups $USER | grep &>/dev/null '\bdocker\b'; then
CAPTAIN="captain"
DOCKER="docker"
else
CAPTAIN="sudo captain"
DOCKER="sudo docker"
fi
commit_id="$(git rev-parse --short HEAD)"
if [[ $R_BUILD == true ]]; then
pushd $ROOT_DIR/r-images
for image in $R_IMAGES ; do
pushd $image
$CAPTAIN test
$DOCKER push hbpmip/$image:$commit_id
$DOCKER push hbpmip/$image:latest
popd
done
popd
fi
if [[ $JAVA_BUILD == true ]]; then
pushd $ROOT_DIR/java-images
for image in $JAVA_IMAGES ; do
pushd $image
$CAPTAIN test
$DOCKER push hbpmip/$image:$commit_id
$DOCKER push hbpmip/$image:latest
popd
done
popd
fi