-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-local.sh
executable file
·93 lines (75 loc) · 1.95 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
#!/usr/bin/env bash
set -e
cd -Pe $(dirname $0)
WORKING_DIR=$(pwd)
usage() {
cat <<EOF
$1
Usage:
Commands:
help Opens this menu
clean Create and populate a new database docker image
EOF
exit 1
}
main() {
case "$1" in
help|[-]*help) usage "I cant even with this...";;
clean|start) createDatabase; shift;;
esac
syntheticRecordsBuilder
loadDatabase $@
}
syntheticRecordsBuilder() {
cd $WORKING_DIR/docker
docker build -t vasdvp/health-apis-synthetic-records-builder:local .
cd $WORKING_DIR
}
createDatabase() {
echo "stop and remove dqdb"
docker stop "dqdb" || true && docker rm "dqdb" || true
#SQL_SERVER_IMAGE=mcr.microsoft.com/mssql/server:2017-latest
SQL_SERVER_IMAGE=mcr.microsoft.com/azure-sql-edge:latest
echo "using image $SQL_SERVER_IMAGE"
# SQL Server Docker Image (you don't have to install anything)
docker pull $SQL_SERVER_IMAGE
# Run docker image with local configuration
[ -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 "$SQL_SERVER_IMAGE"
# 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 $@