diff options
author | Jongmok Hong <jongmok@google.com> | 2018-09-11 10:15:33 +0900 |
---|---|---|
committer | Jongmok Hong <jongmok@google.com> | 2018-09-12 15:24:03 +0900 |
commit | 94696902d2bd801d0a96451d1d500a5b5543048c (patch) | |
tree | da7aa273910f5bd482fbc249d12039807cab06ec | |
parent | fcc9a3f1bed4357fca5d5816502d153f251b38b2 (diff) | |
download | test_serving-94696902d2bd801d0a96451d1d500a5b5543048c.tar.gz |
Update deploy code to include frontend codes.
Test: ./script/deploy-webapp.sh dev
Bug: 74575555
Change-Id: I439eee0f4db738cfdffa1ee8897f601fbb153200
-rw-r--r-- | gae/app.yaml | 11 | ||||
-rw-r--r-- | gae/frontend/angular.json | 2 | ||||
-rwxr-xr-x | gae/script/deploy-webapp.sh | 33 | ||||
-rw-r--r-- | gae/webapp/src/webapp_main.py | 9 |
4 files changed, 40 insertions, 15 deletions
diff --git a/gae/app.yaml b/gae/app.yaml index c2b8dfe..374c07c 100644 --- a/gae/app.yaml +++ b/gae/app.yaml @@ -19,12 +19,13 @@ handlers: - url: /_ah/api/.* script: webapp.src.endpoint_main.api -- url: /favicon\.ico - static_files: favicon.ico - upload: favicon\.ico +- url: /(.*\.(html|js|css|txt|ico)) + static_files: webapp/static/\1 + upload: webapp/static/(.*\.(html|js|css|txt|ico)) -- url: /bootstrap - static_dir: webapp/static/bootstrap +- url: /((build|device|job|lab|schedule)([?&/].*)?)? + static_files: webapp/static/index.html + upload: webapp/static/index.html - url: /.* script: webapp.src.webapp_main.app diff --git a/gae/frontend/angular.json b/gae/frontend/angular.json index e1c4e1a..ca84a43 100644 --- a/gae/frontend/angular.json +++ b/gae/frontend/angular.json @@ -13,7 +13,7 @@ "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist/frontend", + "outputPath": "dist", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", diff --git a/gae/script/deploy-webapp.sh b/gae/script/deploy-webapp.sh index f3cc91e..aeea2a0 100755 --- a/gae/script/deploy-webapp.sh +++ b/gae/script/deploy-webapp.sh @@ -19,6 +19,39 @@ if [ "$#" -ne 1 ]; then exit 1 fi +NPM_PATH=$(which npm) +NG_PATH=$(which ng) +if [ ! -f "${NPM_PATH}" ]; then + echo "Cannot find npm in your PATH." + echo "Please install node.js and npm to deploy frontend." + exit 0 +fi +if [ ! -f "${NG_PATH}" ]; then + echo "Cannot find Angular CLI in your PATH." + echo "Please install Angular CLI to deploy frontend." + exit 0 +fi + +pushd frontend +echo "Installing frontend dependencies..." +npm install + +echo "Removing files in dist directory..." +rm -r dist/* + +echo "Building frontend codes..." +if [ $1 = "local" ]; then + ng build +else + ng build --prod +fi +popd + +echo "Copying frontend files to webapp/static directory..." +rm -rf webapp/static/ +mkdir webapp/static +cp -r frontend/dist/* webapp/static/ + if [ $1 = "public" ]; then SERVICE="vtslab-schedule" elif [ $1 = "local" ]; then diff --git a/gae/webapp/src/webapp_main.py b/gae/webapp/src/webapp_main.py index 380db83..f5c256d 100644 --- a/gae/webapp/src/webapp_main.py +++ b/gae/webapp/src/webapp_main.py @@ -19,10 +19,6 @@ import os import webapp2 -from webapp.src.dashboard import build_list -from webapp.src.dashboard import device_list -from webapp.src.dashboard import job_list -from webapp.src.dashboard import schedule_list from webapp.src.handlers import base from webapp.src.scheduler import device_heartbeat from webapp.src.scheduler import job_heartbeat @@ -49,11 +45,6 @@ config['webapp2_extras.sessions'] = { app = webapp2.WSGIApplication( [ - ("/", MainPage), ("/build", build_list.BuildPage), - ("/device", device_list.DevicePage), ("/job", job_list.JobPage), - ("/create_job", job_list.CreateJobPage), - ("/create_job_template", job_list.CreateJobTemplatePage), - ("/result", MainPage), ("/schedule", schedule_list.SchedulePage), ("/tasks/schedule", periodic.PeriodicScheduler), ("/tasks/device_heartbeat", device_heartbeat.PeriodicDeviceHeartBeat), ("/tasks/job_heartbeat", job_heartbeat.PeriodicJobHeartBeat), |