forked from michaelfig/mediasoup-broadcast-example
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·66 lines (61 loc) · 1.79 KB
/
build.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
#! /bin/sh
set -e
thisdir=`dirname "$0"`
REGISTRY=${REGISTRY-michaelfig}
NAME=mediasoup-broadcast-example
VERSION=`sed -ne '/^ *"version":/{ s/^.* "version": *"\([^"]*\)".*/\1/; p; q; }' "$thisdir"/package.json`
COTURNS_VERSION=4.5.0.7
# If KUBE_CONTEXT=example, use --kube-context=example and -fcharts/example.yaml
KUBE_CONTEXT=${KUBE_CONTEXT-`kubectl config current-context`}
export KUBE_CONTEXT
case "$1" in
build)
cd "$thisdir"
rm -rf _deps
mkdir _deps
for f in package*.json; do
sed -e 's/^ "version": ".*",/ "version": "1.0.0",/' "$f" > _deps/"$f"
done
docker build -t michaelfig/mediasoup-broadcast-example:latest .
;;
build-coturns)
cd "$thisdir"
docker build -t michaelfig/coturns:latest coturns
;;
push)
cmd="$1"
shift
for TAG in latest $VERSION ${1+"$@"}; do
docker tag michaelfig/mediasoup-broadcast-example:latest $REGISTRY/mediasoup-broadcast-example:$TAG
docker push $REGISTRY/mediasoup-broadcast-example:$TAG
done
;;
push-coturns)
cmd="$1"
shift
for TAG in latest $COTURNS_VERSION ${1+"$@"}; do
docker tag michaelfig/coturns:latest $REGISTRY/coturns:$TAG
docker push $REGISTRY/coturns:$TAG
done
;;
upgrade|install)
cd "$thisdir"
cmd="$1"
shift
# Need --recreate-pods if hostNetworkIP is specified.
# Otherwise, the old pod is never terminated for the new one to leave Pending.
if grep -q '^ *hostNetworkIP:' charts/"$KUBE_CONTEXT".yaml; then
RECREATE=${RECREATE---recreate-pods}
fi
helm --kube-context="$KUBE_CONTEXT" upgrade \
$RECREATE --install $NAME -f charts/"$KUBE_CONTEXT".yaml --set=image.tag=$VERSION \
charts/$NAME ${1+"$@"}
;;
"" | help)
echo "Run: \`$0 upgrade' to helm upgrade using KUBE_CONTEXT=$KUBE_CONTEXT"
;;
*)
cmd="$1"
shift
helm --kube-context="$KUBE_CONTEXT" "$cmd" $NAME ${1+"$@"}
esac