-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.sh
executable file
·85 lines (69 loc) · 2.6 KB
/
run.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
#!/bin/bash
declare project_dir=$(dirname "$0")
declare dc_app_deps=${project_dir}/docker/docker-compose.yml
declare dc_app=${project_dir}/docker/docker-compose-app.yml
declare dc_monitoring=${project_dir}/docker/docker-compose-grafana-stack.yml
declare techbuzz="techbuzz"
function build_image_jib() {
./mvnw -pl post-service clean package -DskipTests jib:dockerBuild -Dimage=sivaprasadreddy/techbuzz-post-service
./mvnw -pl vote-service clean package -DskipTests jib:dockerBuild -Dimage=sivaprasadreddy/techbuzz-vote-service
}
function build_apps_buildpacks() {
./mvnw -pl post-service clean spring-boot:build-image -Dspring-boot.build-image.imageName=sivaprasadreddy/techbuzz-post-service
./mvnw -pl vote-service clean spring-boot:build-image -Dspring-boot.build-image.imageName=sivaprasadreddy/techbuzz-vote-service
}
function build_apps() {
build_image_jib
}
function start() {
echo "Starting dependent docker containers...."
docker-compose -f "${dc_app_deps}" up --build --force-recreate -d
docker-compose -f "${dc_app_deps}" logs -f
}
function stop() {
echo "Stopping dependent docker containers...."
docker-compose -f "${dc_app_deps}" stop
docker-compose -f "${dc_app_deps}" rm -f
}
function restart() {
stop
start
}
function start_app() {
echo "Starting ${techbuzz} and dependencies...."
build_apps
docker-compose -f "${dc_app_deps}" -f "${dc_app}" up --build --force-recreate -d
docker-compose -f "${dc_app_deps}" -f "${dc_app}" logs -f
}
function stop_app() {
echo 'Stopping all....'
docker-compose -f "${dc_app_deps}" -f "${dc_app}" stop
docker-compose -f "${dc_app_deps}" -f "${dc_app}" rm -f
}
function start_grafana() {
echo 'Starting Grafana Observability Stack....'
docker-compose -f "${dc_monitoring}" up --build --force-recreate -d
docker-compose -f "${dc_monitoring}" logs -f
}
function stop_monitoring() {
echo 'Stopping Grafana Observability Stack....'
docker-compose -f "${dc_monitoring}" stop
docker-compose -f "${dc_monitoring}" rm -f
}
function start_all() {
echo "Starting ${techbuzz} and dependencies...."
#build_apps
docker-compose -f "${dc_app_deps}" -f "${dc_app}" -f "${dc_monitoring}" up --build --force-recreate -d
docker-compose -f "${dc_app_deps}" -f "${dc_app}" -f "${dc_monitoring}" logs -f
}
function stop_all() {
echo 'Stopping all....'
docker-compose -f "${dc_app_deps}" -f "${dc_app}" -f "${dc_monitoring}" stop
docker-compose -f "${dc_app_deps}" -f "${dc_app}" -f "${dc_monitoring}" rm -f
}
action="start"
if [[ "$#" != "0" ]]
then
action=$*
fi
eval "${action}"