-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildRadio.sh
executable file
·103 lines (95 loc) · 3 KB
/
buildRadio.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
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
REGISTRY_HOST="localhost"
REGISTRY_PORT="5000"
K8S_CONTEXT="minikube"
command -v docker >/dev/null 2>&1 || { echo >&2 "I require docker but it's not installed. Aborting."; exit 1; }
command -v kubectl >/dev/null 2>&1 || { echo >&2 "I require kubtctl but it's not installed. Aborting."; exit 1; }
command -v kubectx >/dev/null 2>&1 || { echo >&2 "I require kubectx but it's not installed. Aborting."; exit 1; }
command -v kubens >/dev/null 2>&1 || { echo >&2 "I require kubens but it's not installed. Aborint."; exit 1; }
LAUNCH_NAMESPACE="radio"
LAUNCH_AFTER_BUILD="false"
function version() {
printf "${0} v0.0.51\n"
}
function check_env() {
[ -z ${DOCKER_HOST} ] && { printf "To use your local docker environment, use the --use-sysdocker flag!\nTo use the minikube docker environment, use 'eval \$(minikube docker-env)'\n"; exit 1; }
}
function switchNS {
kubectx ${K8S_CONTEXT}
kubens ${LAUNCH_NAMESPACE}
}
# Create namespace
function createNS {
kubectl create ns ${LAUNCH_NAMESPACE} && switchNS
}
while test $# -gt 0; do
case "$1" in
-h|--help)
version
echo "options:"
echo "-h, --help Its what youre looking at!"
echo "-b, --build (Re)build CloudTunes docker images"
echo "-B, --browser Launch CloudTunes service in browser"
echo "-l, --launch Launch CloudTunes"
echo "-d, --destroy Destroy CloudTunes"
echo "-F, --full Destroy, rebuild, then relaunch CloudTunes"
echo "--use-sysdocker Bypass enviornment checking"
echo "-v, --version Show version"
exit 0
;;
--use-sysdocker)
ENV_SKIP=1
shift
;;
-b|--build)
[[ ${ENV_SKIP} == "1" ]] || check_env
createNS
switchNS
for MDIR in `ls -d */`; do
docker build -t ${REGISTRY_HOST}:${REGISTRY_PORT}/${MDIR%/}:latest ./${MDIR}
docker push ${REGISTRY_HOST}:${REGISTRY_PORT}/${MDIR%/}:latest
done
shift
;;
-B|--browser)
minikube service -n radio radio-fe-app
exit 0
;;
-l|--launch)
[[ $ENV_SKIP = "1" ]] || check_env
switchNS
for MDIR in `ls -d */`; do
kubectl create -f ${MDIR}/deploy/
done
exit 0
;;
-d|--destroy)
[[ $ENV_SKIP = "1" ]] || check_env
switchNS
for MDIR in `ls -d */`; do
kubectl delete -f ${MDIR}/deploy/
done
exit 0
;;
-F|--full)
[[ $ENV_SKIP = "1" ]] || check_env
switchNS
for MDIR in `ls -d */`; do
kubectl delete -f ${MDIR}/deploy
docker build -t ${REGISTRY_HOST}:${REGISTRY_PORT}/${MDIR%/}:latest ./${MDIR}
docker push ${REGISTRY_HOST}:${REGISTRY_PORT}/${MDIR%/}:latest
kubectl create -f ${MDIR}/deploy/
done
exit 0
;;
-v|--version)
version
exit 0
;;
*)
break
;;
esac
done
echo ":)"
exit 0