-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-and-deploy.sh
executable file
·48 lines (38 loc) · 1.16 KB
/
build-and-deploy.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
#!/bin/bash
set -e
SKIP_SBT=false
CODE_CLEAN=true
DEPLOY=true
tag=`git rev-parse --short HEAD`
if [[ -n $(git status -s) ]] ; then
CODE_CLEAN=false
echo "You have uncommited files. Use date as image tag instead of git commit."
tag=`date +'%Y-%m-%d-%s'`
fi
if [ "$SKIP_SBT" = false ] ; then
echo "Build jar ..."
sbt clean generateGRPCCode
if [[ -n $(git status -s) ]] && [ "$CODE_CLEAN" = true ] ; then
echo "Code changed after build grpc files. Please check."
exit 1
fi
sbt compile assembly
else
echo "NOTE: Skip sbt build. Please make sure you've done \"sbt compile assembly\""
fi
image="docker-hosted.binwang.me:30008/rss_brain:$tag"
echo "Building image $image ..."
docker build -t $image .
echo "Pushing image ..."
docker push $image
if [ "$DEPLOY" = false ] ; then
echo "DEPLOY is set to failse, skip deploy to Kubernetes"
exit 0
fi
echo "Deploying iamge $image to Kubernetes ..."
echo "Deploying rss-brain-fetcher ..."
kubectl set image deployment/rss-brain-fetcher rss-brain-fetcher=$image
echo "Deployed rss-brain-fetcher"
echo "Deploying rss-brain-grpc ..."
kubectl set image deployment/rss-brain-grpc rss-brain-grpc=$image
echo "Deployed rss-brain-grpc"