forked from OpenPEPPOL/pracc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_server.sh
executable file
·48 lines (34 loc) · 1016 Bytes
/
run_server.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
#!/usr/bin/env bash
# exit on any failure
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT
# get script dir
script_dir=$(cd $(dirname $0) && pwd)
source ${script_dir}/functions.sh
# change to project root
pushd ${script_dir}/../.. > /dev/null
(
container_id=$(docker ps -q --filter "ancestor=pracc")
if [[ -n "$container_id" ]]; then
info "stop running container ${container_id}"
docker container stop ${container_id} &> /dev/null
fi
info "remove pracc images"
docker image rm -f pracc &> /dev/null
) &
info "clean target"
rm -rf target
info "check schematron and create xml instances"
./gradlew check
info "running build.sh"
${script_dir}/build.sh
info "building pracc image"
docker build --tag pracc .
info "running pracc image"
docker run --rm -p 80:8000 -d pracc:latest
trap - EXIT
# go back
popd > /dev/null