forked from phyloviz/phyloDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-docker.sh
executable file
·105 lines (82 loc) · 2.16 KB
/
build-docker.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
98
99
100
101
102
103
104
105
#!/bin/bash
# Move into current script's directory.
PROJ_ROOT="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
pushd "$PROJ_ROOT" # cd current directory
# Built the solution JAR files if necessary.
echo ""
echo "#####"
echo "##### Checking algorithms-1.0.jar..."
echo "#####"
echo ""
if [ ! -f "$PROJ_ROOT/algorithms/target/algorithms-1.0.jar" ] ; then
cd "algorithms"
mvn package -Dmaven.test.skip=true
cd "$PROJ_ROOT"
else
echo "> Found: algorithms-1.0.jar, skipping build."
fi
echo ""
echo ""
echo ""
echo "#####"
echo "##### Checking phylodb-1.0.jar..."
echo "#####"
echo ""
if [ ! -f "$PROJ_ROOT/phylodb/build/libs/phylodb-1.0.0.jar" ] ; then
cd "phylodb"
gradle bootJar
cd "$PROJ_ROOT"
else
echo "> Found: algorithms-1.0.jar, skipping build."
fi
echo ""
echo ""
echo ""
echo "#####"
echo "##### Checking Docker files..."
echo "#####"
echo ""
# Create Docker drive structure.
INSTANCE_1_DIR="$PROJ_ROOT/instance1"
PLUGINS_DIR="$INSTANCE_1_DIR/db/plugins"
mkdir -p "$INSTANCE_1_DIR/db/data"
mkdir -p "$INSTANCE_1_DIR/db/logs"
mkdir -p "$PLUGINS_DIR"
mkdir -p "$INSTANCE_1_DIR/app/logs"
# Copy the algorithms JAR file.
if [ ! -f "$PLUGINS_DIR/algorithms-1.0.jar" ] ; then
echo ""
echo "> Copying algorithms-1.0.jar."
cp "$PROJ_ROOT/algorithms/target/algorithms-1.0.jar" "$PLUGINS_DIR/"
echo ""
fi
# Get Neo4j's APOC JAR files.
if [ ! -f "$PLUGINS_DIR/apoc-4.4.0.5-all.jar" ] ; then
echo ""
echo "> Dowloading apoc-4.4.0.5-all.jar."
cd "$PLUGINS_DIR"
wget "https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.4.0.5/apoc-4.4.0.5-all.jar"
cd "$PROJ_ROOT"
echo ""
fi
echo "> Done."
# Build the Docker image.
echo ""
echo ""
echo ""
echo "#####"
echo "##### Checking the Docker image..."
echo "#####"
echo ""
# Helper: Docker permissions.
# https://stackoverflow.com/questions/51342810/how-to-fix-dial-unix-var-run-docker-sock-connect-permission-denied-when-gro
# https://stackoverflow.com/a/66079754/1708550
cd "$PROJ_ROOT/phylodb"
# Change group ID to docker.
newgrp docker
docker build -t phylodb .
# Change back to original group ID.
newgrp
cd ..
# Return to the initial directory.
popd