This repository was archived by the owner on Mar 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrun-application.sh
More file actions
executable file
·82 lines (69 loc) · 2.11 KB
/
run-application.sh
File metadata and controls
executable file
·82 lines (69 loc) · 2.11 KB
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
#!/usr/bin/env bash
set -e
ENVIRONMENT=${ENVIRONMENT:-beta}
REGISTERS=${REGISTERS:-"country"}
case ${ENVIRONMENT} in
beta) DOMAIN="register.gov.uk";;
discovery) DOMAIN="cloudapps.digital";;
*) DOMAIN="$ENVIRONMENT.openregister.org";;
esac
function on_exit {
echo "Stopping and removing containers..."
docker-compose --file docker-compose.register.yml down
docker-compose -p registers --file docker-compose.basic.yml down
exit
}
function wait_for_http_on_port {
while ! curl "http://localhost:$1" --silent --fail --output /dev/null;
do
if [ $(docker inspect -f {{.State.Running}} $2) != 'true' ]; then
echo "Container $2 unexpectedly stopped while waiting for it to open port $1"
exit 1
fi
echo "Waiting for HTTP on :$1"
sleep 1
done
}
function do_nothing_forever {
tail -f /dev/null
}
trap on_exit EXIT
git submodule update --init
if [ ! -e "./deploy/openregister-java.jar" ]
then
docker run \
--rm \
--volume "$PWD":/usr/src/openregister-java \
--workdir /usr/src/openregister-java \
openjdk:8 \
bash -c "./gradlew assemble"
fi
echo "Starting environment based off \"$ENVIRONMENT\""
echo "Starting basic registers..."
docker-compose -p registers --file docker-compose.basic.yml up -d
wait_for_http_on_port 8081 openregister-basic
for register in "register" "datatype" "field"; do
echo "Loading $register..."
curl \
--fail \
--header "Content-Type: application/uk-gov-rsf" \
--header "Host: $register" \
--data-binary @<(curl "https://$register.$DOMAIN/download-rsf") \
--user foo:bar \
"http://localhost:8081/load-rsf"
done
echo "Starting register..."
docker-compose --file docker-compose.register.yml up -d
wait_for_http_on_port 8080 openregister-register
for register in $REGISTERS; do
echo "Loading $register..."
curl \
--fail \
--header "Content-Type: application/uk-gov-rsf" \
--header "Host: $register" \
--data-binary @<(curl "https://$register.$DOMAIN/download-rsf") \
--user foo:bar \
"http://localhost:8080/load-rsf"
done
echo "Register is ready on http://localhost:8080"
do_nothing_forever