added docker build script
Simon Schön committed
Jun 8, 2022 at 17:16 UTC
0ce81a3f549a3da3282e864c0293de4961c92ac2
1 file changed
+75
docker/docker.build.sh
new
+75
@@ -0,0 +1,75 @@
1
+#!/bin/bash
2
+
3
+MSG="";
4
+PRUNE="false";
5
+
6
+function appendOutput()
7
+{
8
+ if [ -z "${MSG}" ]; then echo -e "\n" > /dev/tty; fi
9
+
10
+ ARGS=$@;
11
+ LINE="${ARGS}\n"
12
+ echo -e "${LINE}" > /dev/tty;
13
+
14
+ MSG="${MSG}${LINE}";
15
+}
16
+
17
+function runDockerBuild()
18
+{
19
+ if [ "${PRUNE}" == "true" ]; then docker system prune -a -f; fi
20
+
21
+ STARTTS=$(date +%s);
22
+ ARGS=$@;
23
+
24
+ BUILD_CMD="docker build -f docker/Dockerfile --force-rm --no-cache ${ARGS} -t meshcentral .";
25
+ appendOutput "Current build: ${BUILD_CMD}";
26
+
27
+ ${BUILD_CMD};
28
+ if [ $? -ne 0 ]; then exit $?; fi
29
+
30
+ ENDTS=$(date +%s);
31
+ DIFSEC=$((${ENDTS}-${STARTTS}));
32
+ if [ ${DIFSEC} -ge 60 ]; then
33
+ TMPMIN=$((${DIFSEC}/60));
34
+ TMPSEC=$((${DIFSEC}%60));
35
+
36
+ if [ ${TMPMIN} -ge 60 ]; then
37
+ TMPHOUR=$((${TMPMIN}/60));
38
+ TMPMIN=$((${TMPMIN}%60));
39
+
40
+ appendOutput "\tBuild time: ${TMPHOUR} hr ${TMPMIN} min ${TMPSEC} sec";
41
+ else appendOutput "\tBuild time: ${TMPMIN} min ${TMPSEC} sec"; fi
42
+ else appendOutput "\tBuild time: ${DIFSEC} sec"; fi
43
+
44
+ IMG_SIZE=$(docker image inspect meshcentral | grep -e "\"Size\"" | tr -d '",' | sed -E "s/\s*Size:\s*//");
45
+ expr $IMG_SIZE + 0;
46
+ appendOutput "\tImage size: ${IMG_SIZE} ($((${IMG_SIZE}/1024/1024))M)";
47
+
48
+ appendOutput "\n";
49
+
50
+ return 0;
51
+}
52
+
53
+
54
+parent_path=$(dirname -- $(dirname -- "$( readlink -f -- "$0"; )"));
55
+if [ "${parent_path}" != "$(pwd -P)" ]; then
56
+ echo -e "change working directory to: ${parent_path}" > /dev/tty;
57
+ cd "${parent_path}";
58
+fi
59
+
60
+if ! [ -z $1 ] && [ "${1}" == "prune" ]; then PRUNE="true"; fi
61
+
62
+runDockerBuild;
63
+#runDockerBuild --build-arg DISABLE_MINIFY=yes;
64
+#runDockerBuild --build-arg DISABLE_TRANSLATE=yes;
65
+#runDockerBuild --build-arg DISABLE_MINIFY=yes --build-arg DISABLE_TRANSLATE=yes;
66
+
67
+#runDockerBuild --build-arg INCLUDE_MONGOTOOLS=yes;
68
+#runDockerBuild --build-arg INCLUDE_MONGOTOOLS=yes --build-arg DISABLE_MINIFY=yes;
69
+#runDockerBuild --build-arg INCLUDE_MONGOTOOLS=yes --build-arg DISABLE_TRANSLATE=yes;
70
+#runDockerBuild --build-arg INCLUDE_MONGOTOOLS=yes --build-arg DISABLE_MINIFY=yes --build-arg DISABLE_TRANSLATE=yes;
71
+
72
+echo "";
73
+echo -e $MSG;
74
+
75
+exit 0;