-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-local.sh
executable file
·95 lines (78 loc) · 2.01 KB
/
run-local.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
#!/usr/bin/env bash
set -e
if [[ "$OSTYPE" == "darwin"* ]]
then
brew install coreutils
WORKING_DIR=$(greadlink -f $(dirname $0))
else
WORKING_DIR=$(readlink -f $(dirname $0))
fi
cd $WORKING_DIR
usage() {
cat <<EOF
$1
Usage:
Commands:
help Opens this menu
clean Drops/Rebuilds the tables in an already existing database
start Creates a brand new database and loads it
EOF
exit 1
}
main() {
case "$1" in
help|[-]*help) usage "I cant even with this...";;
start) createDatabase; shift; break;;
esac
syntheticRecordsBuilder
loadDatabase $@
}
syntheticRecordsBuilder() {
cd $WORKING_DIR/docker
docker build -t vasdvp/health-apis-synthetic-records-builder:local .
cd $WORKING_DIR
}
createDatabase() {
# SQL Server Docker Image (You don't have to install anything!!!)
docker pull mcr.microsoft.com/mssql/server:2017-latest
# Run the docker image, but make sure its configuration matches the local ones
# that were set.
[ -f "environments/local.conf" ] && . environments/local.conf
[ -z "$FLYWAY_PASSWORD" ] && "Help! I can't seem to find my password(FLYWAY_PASSWORD)!" && exit 1
docker run \
--name "dqdb" \
-e 'ACCEPT_EULA=Y' \
-e "SA_PASSWORD=$FLYWAY_PASSWORD" \
-p 1433:1433 \
-d mcr.microsoft.com/mssql/server:2017-latest
# Needs time to create SA user
sleep 10
}
howToBuild() {
if [ -n "${BUILD_MODE:-}" ]; then echo $BUILD_MODE; return; fi
if [[ "$(uname)" == *Linux* ]]; then echo docker; return; fi
echo native
}
buildWithDocker() {
docker run --rm \
-e ENVIRONMENT="local" \
-v $(pwd):/root/synthetic-records \
-v ~/.m2:/root/.m2 \
-e NEXUS_USERNAME="${NEXUS_USERNAME}" \
-e NEXUS_PASSWORD="${NEXUS_PASSWORD}" \
--network host \
vasdvp/health-apis-synthetic-records-builder:local \
./root/synthetic-records/build.sh $@
}
buildNatively() {
ENVIRONMENT=local ./build.sh $@
}
loadDatabase() {
if [ "$(howToBuild)" == "docker" ]
then
buildWithDocker $@
else
buildNatively $@
fi
}
main $@