generated from hmcts/service-hmcts-crime-springboot-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-in-docker.sh
More file actions
executable file
·73 lines (58 loc) · 1.71 KB
/
run-in-docker.sh
File metadata and controls
executable file
·73 lines (58 loc) · 1.71 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
#!/usr/bin/env sh
print_help() {
echo "Script to run docker containers for Spring Boot Template API service
Usage:
./run-in-docker.sh [OPTIONS]
Options:
--clean, -c Clean and install current state of source code
--install, -i Install current state of source code
--param PARAM=, -p PARAM= Parse script parameter
--help, -h Print this help block
Available parameters:
"
}
# script execution flags
GRADLE_CLEAN=false
GRADLE_INSTALL=false
# TODO custom environment variables application requires.
# TODO also consider enlisting them in help string above ^
# TODO sample: CP_CDK_DB_PASSWORD Defaults to 'dev'
# environment variables
#CP_CDK_DB_PASSWORD=dev
#S2S_URL=localhost
#S2S_SECRET=secret
execute_script() {
cd $(dirname "$0")/..
if [ ${GRADLE_CLEAN} = true ]
then
echo "Clearing previous build.."
./gradlew clean
fi
if [ ${GRADLE_INSTALL} = true ]
then
echo "Assembling distribution.."
./gradlew assemble
fi
# echo "Assigning environment variables.."
#
# export CP_CDK_DB_PASSWORD=${CP_CDK_DB_PASSWORD}
# export S2S_URL=${S2S_URL}
# export S2S_SECRET=${S2S_SECRET}
echo "Bringing up docker containers.."
docker compose up
}
while true ; do
case "$1" in
-h|--help) print_help ; shift ; break ;;
-c|--clean) GRADLE_CLEAN=true ; GRADLE_INSTALL=true ; shift ;;
-i|--install) GRADLE_INSTALL=true ; shift ;;
-p|--param)
case "$2" in
# CP_CDK_DB_PASSWORD=*) CP_CDK_DB_PASSWORD="${2#*=}" ; shift 2 ;;
# S2S_URL=*) S2S_URL="${2#*=}" ; shift 2 ;;
# S2S_SECRET=*) S2S_SECRET="${2#*=}" ; shift 2 ;;
*) shift 2 ;;
esac ;;
*) execute_script ; break ;;
esac
done