a spring boot ionic simple app

deploy.sh 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # Warning: this script has only been tested on macOS Sierra. There's a good chance
  3. # it won't work on other operating systems. If you get it working on another OS,
  4. # please send a pull request with any changes required. Thanks!
  5. set -e
  6. ### CloudFoundry CLI utilities
  7. CLOUD_DOMAIN=${DOMAIN:-run.pivotal.io}
  8. CLOUD_TARGET=api.${DOMAIN}
  9. function login(){
  10. cf api | grep ${CLOUD_TARGET} || cf api ${CLOUD_TARGET} --skip-ssl-validation
  11. cf apps | grep OK || cf login
  12. }
  13. function app_domain(){
  14. D=`cf apps | grep $1 | tr -s ' ' | cut -d' ' -f 6 | cut -d, -f1`
  15. echo $D
  16. }
  17. function deploy_service(){
  18. N=$1
  19. D=`app_domain $N`
  20. JSON='{"uri":"http://'$D'"}'
  21. cf create-user-provided-service $N -p $JSON
  22. }
  23. ### Installation
  24. cd `dirname $0`
  25. r=`pwd`
  26. echo $r
  27. ## Reset
  28. cf d -f ionic-server
  29. cf a
  30. # Stormpath
  31. stormpathApiKeyId=`cat ~/.stormpath/apiKey.properties | grep apiKey.id | cut -f3 -d\ `
  32. stormpathApiKeySecret=`cat ~/.stormpath/apiKey.properties | grep apiKey.secret | cut -f3 -d\ `
  33. # Deploy the server
  34. cd $r/server
  35. mvn clean package
  36. cf push -p target/*jar ionic-server --no-start --random-route
  37. cf set-env ionic-server STORMPATH_API_KEY_ID $stormpathApiKeyId
  38. cf set-env ionic-server STORMPATH_API_KEY_SECRET $stormpathApiKeySecret
  39. cf set-env ionic-server FORCE_HTTPS true
  40. cf start ionic-server
  41. # Get the URL for the server
  42. serverUri=https://`app_domain ionic-server`
  43. # Deploy the client
  44. cd $r/client
  45. npm run clean
  46. # replace the server URL in the client
  47. sed -i -e "s|http://localhost:8080|$serverUri|g" src/app/app.module.ts
  48. npm install && ionic build ios
  49. # deploy client to phone
  50. ionic run ios
  51. # cleanup changed files
  52. git checkout $r/client
  53. rm $r/client/src/app/app.module.ts-e