-
Notifications
You must be signed in to change notification settings - Fork 18
/
update.sh
28 lines (25 loc) · 843 Bytes
/
update.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
#!/bin/bash
echo "Load environment variable"
# find public IP address
alias myip='curl -s "http://checkip.dyndns.org/" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | head -1'
# set SERVER environment variable according to public IP address
case $(myip) in
54.123.45.678 ) SERVER="dev"
;;
52.234.56.789 ) SERVER="stage"
;;
52.345.67.890 ) SERVER="live"
;;
* ) SERVER=""
;;
esac
# build api container
if [ $# -eq 0 ]
then docker build -t platform_api:latest .
else
docker build -t platform_api:$1 .
docker tag -f platform_api:$1 platform_api:latest
fi
# stop and restart docker api container
cd $WORKSPACE && ./manage-leap-components.sh --operation stop --server $SERVER --component api
cd $WORKSPACE && ./manage-leap-components.sh --operation start --server $SERVER --component api