aboutsummaryrefslogtreecommitdiff
path: root/setup/docker/build.sh
blob: f32335ead44c8e0731b006401f77859cdf877f7a (plain)
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
#!/bin/bash

which mvn &> /dev/null || { echo >&2 "Maven package cant be found on path. Aborting."; exit 1; }
which awk &> /dev/null  || { echo >&2 "Awk package cant be found on path. Aborting."; exit 1; }
which docker &> /dev/null  || { echo >&2 "Docker package cant be found on path. Aborting."; exit 1; }
mvn package || { echo >&2 "Maven package has failed. Aborting."; exit 1; }

export company="tananaev"
export software="traccar"
export version=$(head -n 10 ./pom.xml |grep version|cut -d ">" -f2|cut -d"<" -f1)

tmp="./setup/docker/tmp"

mkdir -p ${tmp}

cat ./setup/traccar.xml | awk '/config.default/ && !modif { print;printf("    <entry key=\"web.debug\">true</entry>\n");next; modif=1 } {print}'  > ${tmp}/traccar.xml
cp -rf ./setup/default.xml ${tmp}
cp -rf ./schema ${tmp}/schema
cp -rf ./target/tracker-server.jar ${tmp}/traccar-server.jar
cp -rf ./target/lib ${tmp}/lib
if [ -d ./traccar-web/web ]; then
  cp -rf ./traccar-web/web ${tmp}/web
else
  mkdir ${tmp}/web
fi

docker build -t ${company}/${software}:${version} ./setup/docker/

rm -rf ${tmp}