-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.sh
executable file
·84 lines (77 loc) · 1.75 KB
/
make.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
#!/usr/bin/env bash
# Error Handling
function on_error() {
echo "error: [ ${BASH_SOURCE[1]} at line ${BASH_LINENO[0]} ]";
}
set -o errtrace
trap on_error ERR
dir="$(dirname "$0")"
source "${dir}/gcp_provisioning.sh"
function docker_build() {
docker-compose up -d --build
}
function docker_cleanup() {
docker-compose down
docker system prune
}
function usage() {
echo "Usage: ./make.sh option"
echo "Options: docker-build, -- run docker-compose up -d --build"
echo " docker-cleanup -- run docker-compose down & system prune"
echo " gcp-build (optional flag: -t v0.x.x), -- build Docker image and push to gcr.io"
echo " gcp-create, -- run GCP provisioning and deployment"
echo " gcp-destroy, -- destroy GCP resorces"
echo "Examples: "
echo " ./make.sh -t 0.1.10 gcp-build"
echo " ./make.sh -t 0.1.10 -c 3 gcp-deploy"
}
while [[ $# -gt 0 ]]; do
case $1 in
gcp-build)
gcp_build "$TAG";
shift
;;
gcp-create)
gcp_create;
./test.sh remote;
shift
;;
gcp-deploy)
gcp_deploy "$TAG" "$COUNT";
./test.sh remote;
shift
;;
gcp-destroy)
gcp_destroy;
shift
;;
docker-build)
docker_build;
./test.sh local;
shift
;;
docker-cleanup)
docker_cleanup;
shift
;;
-t)
TAG=$2;
shift
;;
-c)
COUNT=$3;
shift
;;
test)
test;
shift
;;
--help|help)
usage;
shift
;;
*)
echo "Check ./make.sh help for more information";
shift
esac
done