forked from dhis2/dhis2-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-dev.sh
executable file
·69 lines (50 loc) · 1.7 KB
/
build-dev.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
#!/usr/bin/env bash
#
## bash environment
#
if test "$BASH" = "" || "$BASH" -uc "a=();true \"\${a[@]}\"" 2>/dev/null; then
# Bash 4.4, Zsh
set -euo pipefail
else
# Bash 4.3 and older chokes on empty arrays with set -u.
set -eo pipefail
fi
shopt -s nullglob globstar
#
## script environment
#
D2CLUSTER="${1:-}"
IMAGE=dhis2/core
TAG=local
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT="$DIR/.."
ARTIFACTS="$ROOT/docker/artifacts"
print() {
echo -e "\033[1m$1\033[0m" 1>&2
}
#
## The Business
#
# Requires maven to be on the classpath
# Skips clean and test phases
# Also skips copying test resources and compiling tests
print "Building dhis2-core..."
MAVEN_BUILD_OPTS="-Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.test.skip=true"
mvn clean install -T1C -Pdev -Pjdk11 -f $DIR/pom.xml -pl -dhis-web-embedded-jetty $MAVEN_BUILD_OPTS
mvn clean install -T1C -Pdev -Pjdk11 -f $DIR/dhis-web/pom.xml $MAVEN_BUILD_OPTS
rm -rf "$ARTIFACTS/*"
mkdir -p "$ARTIFACTS"
cp -f "$DIR/dhis-web/dhis-web-portal/target/dhis.war" "$ARTIFACTS/dhis.war"
print "Build succeeded, creating Docker image $IMAGE:$TAG..."
cd $ARTIFACTS
sha256sum ./dhis.war > ./sha256sum.txt
md5sum ./dhis.war > ./md5sum.txt
ONLY_DEFAULT=1 $ROOT/docker/build-containers.sh $IMAGE:$TAG $TAG
print "Successfully created Docker image $IMAGE:$TAG"
if test -z $D2CLUSTER; then
print "No cluster name specified, skipping deploy"
else
print "Deploying to d2 cluster $D2CLUSTER..."
d2 cluster up $D2CLUSTER --image $IMAGE:$TAG
d2 cluster logs $D2CLUSTER
fi