-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·65 lines (56 loc) · 1.49 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
configGenerate() {
cp app.yaml app-deploy.yaml
[[ ! -z $GOOGLE_APPLICATION_CREDENTIALS ]] && echo " GOOGLE_APPLICATION_CREDENTIALS: \"$GOOGLE_APPLICATION_CREDENTIALS\"" >> app-deploy.yaml
echo "Config generated!"
}
remote() {
if [ -n "$1" ]; then PROJECT_ID=$1; fi
if gcloud projects describe "$PROJECT_ID" 2>&1 > /dev/null; then
echo "Project ID $PROJECT_ID"
else
echo Project $1 Not Found!
exit 1
fi
echo "Deploy App engine & Cron job"
configGenerate
_GAE_VERSION=${_GAE_VERSION:-test}
_GAE_PROMOTE=${_GAE_PROMOTE:---no-promote}
echo "[ENV] $_GAE_VERSION"
echo "[CMD] cloud app deploy --project $PROJECT_ID -q app-deploy.yaml $_GAE_PROMOTE -v $_GAE_VERSION"
gcloud app deploy --project $PROJECT_ID \
-q app-deploy.yaml \
$_GAE_PROMOTE \
-v $_GAE_VERSION
}
local() {
echo "Run app on local machine, port $1"
configGenerate
dev_appserver.py app-deploy.yaml --port=$1 --log_level=debug --env_var FLASK_DEBUG=1 --application=${PROJECT_ID}
}
usage() {
echo "Usage: deploy.sh local [PORT]"
echo " or: deploy.sh remote [PROJECT_ID]"
echo ""
echo "-----------Parameter-------------"
echo "local : Deploy app in local env"
echo "remote: Deploy app in GAE (need project id)"
echo "config: Generate config file app-deploy.yaml"
}
case "$1" in
local)
if [[ $# -eq 2 ]] ; then
local $2
else
local 8080
fi
;;
remote)
remote $2
;;
config)
echo "Generate config file in app-deploy.yaml"
configGenerate
;;
*) usage ;;
esac