-
Notifications
You must be signed in to change notification settings - Fork 7
/
deploy.sh
executable file
·86 lines (69 loc) · 2.18 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Warning: this script has only been tested on macOS Sierra. There's a good chance
# it won't work on other operating systems. If you get it working on another OS,
# please send a pull request with any changes required. Thanks!
set -e
### CloudFoundry CLI utilities
CLOUD_DOMAIN=${DOMAIN:-run.pivotal.io}
CLOUD_TARGET=api.${DOMAIN}
function login(){
cf api | grep ${CLOUD_TARGET} || cf api ${CLOUD_TARGET} --skip-ssl-validation
cf apps | grep OK || cf login
}
function app_domain(){
D=`cf apps | grep $1 | tr -s ' ' | cut -d' ' -f 6 | cut -d, -f1`
echo $D
}
function deploy_service(){
N=$1
D=`app_domain $N`
JSON='{"uri":"http://'$D'"}'
cf create-user-provided-service $N -p $JSON
}
### Installation
cd `dirname $0`
r=`pwd`
echo $r
## Reset
cf d -f pwa-client
cf d -f pwa-server
cf a
# Stormpath
stormpathApiKeyId=`cat ~/.stormpath/apiKey.properties | grep apiKey.id | cut -f3 -d\ `
stormpathApiKeySecret=`cat ~/.stormpath/apiKey.properties | grep apiKey.secret | cut -f3 -d\ `
# Deploy the server
cd $r/server
mvn clean package
cf push -p target/*jar pwa-server --no-start --random-route
cf set-env pwa-server STORMPATH_API_KEY_ID $stormpathApiKeyId
cf set-env pwa-server STORMPATH_API_KEY_SECRET $stormpathApiKeySecret
# Get the URL for the server
serverUri=https://`app_domain pwa-server`
# Deploy the client
cd $r/client
rm -rf dist
# replace the server URL in the client
sed -i -e "s|https://pwa-server.cfapps.io|$serverUri|g" $r/client/src/app/app.module.ts
npm install && ng build --prod --aot
# Fix filenames in sw.js
python $r/sw.py
cd dist
touch Staticfile
cf push pwa-client --no-start --random-route
cf set-env pwa-client FORCE_HTTPS true
cf start pwa-client
# Get the URL for the client
clientUri=https://`app_domain pwa-client`
# replace the client URL in the server
sed -i -e "s|https://pwa-client.cfapps.io|$clientUri|g" $r/server/src/main/resources/application.properties
# redeploy the server
cd $r/server
mvn package -DskipTests
cf push -p target/*jar pwa-server
# cleanup changed files
git checkout $r/client
git checkout $r/server
rm $r/client/src/app/app.module.ts-e
rm $r/server/src/main/resources/application.properties-e
# show apps and URLs
cf apps