From cd821a034485fa8ea625196f34381b23e497565f Mon Sep 17 00:00:00 2001 From: bmccandless Date: Tue, 28 Apr 2020 14:38:35 -0700 Subject: [PATCH] Update the EB build process to package in scripts (#1434) This is implemented specifically to handle the google analytics script for hosted cellxgene --- server/eb/Makefile | 3 +++ server/eb/README.md | 35 ++++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/server/eb/Makefile b/server/eb/Makefile index a99654c6..2efd2347 100644 --- a/server/eb/Makefile +++ b/server/eb/Makefile @@ -27,6 +27,9 @@ build: clean mkdir -p artifact.dir/server/common/web/static/deploy; \ cp -r static/* artifact.dir/server/common/web/static/deploy; \ fi; \ + if [ -d scripts ] ; then \ + cp -r scripts/* artifact.dir/server/common/web/templates; \ + fi; \ (cd artifact.dir; \ cp -r server/common/web/static static; \ zip -r ../artifact.zip . --exclude server/test/\* server/eb/\* ; ); \ diff --git a/server/eb/README.md b/server/eb/README.md index 4d082d40..a2781f60 100644 --- a/server/eb/README.md +++ b/server/eb/README.md @@ -69,7 +69,7 @@ There are many more options to these commands that may be important or necessary To use this feature, do the following: * In this directory, create a sub directory called "static". - * Copy the files you want to server into this directory + * Copy the files you want to serve into this directory * modify your configuration file to set the location to these file: /static/deploy/ Example: you want to include an "about_legal_tos" and "about_legal_privacy" page to cellxgene. @@ -87,14 +87,35 @@ There are many more options to these commands that may be important or necessary ``` The next step will place these files into the deployment. + +5. Add additional script files to include in HTML page + +Additional scripts can be added using the server/scripts or server/inline_scripts config parameters. +To include these scripts in the deployment, use the following steps: + + * In this directory, create a sub directory called "scripts". + * Copy the script files into this directory + * modify your configuration file to set the location to these file: + - for server/scripts, the path is: /templates/ + - for server/inline_scripts, the path is: + + For example, to add an inline script called "myscript.js": -5. Create the artifact.zip file for the application + ``` + $ mkdir scripts + $ cp /myscript.js scripts/myscript.js + # edit the config.yaml + $ grep inline_scripts config.yaml + inline_scripts : [ myscript.js ] + ``` + +6. Create the artifact.zip file for the application ``` $ make build ``` -6. Flask secret key +7. Flask secret key The application requires as secret key to be provided to flask, the web framework used by cellxgene. There are three ways to provide the secret key: @@ -109,7 +130,7 @@ There are many more options to these commands that may be important or necessary then the AWS Secret Manager region name can be specified in an environment variable: CXG_AWS_SECRET_REGION_NAME. -7. Create an environment +8. Create an environment ``` # name of the environment @@ -128,18 +149,18 @@ There are many more options to these commands that may be important or necessary --envvars CXG_DATAROOT=$CXG_DATAROOT,CXG_CONFIG_FILE=$CXG_CONFIG_FILE ``` -8. Give the elastic beanstalk environment access to the S3 bucket. +9. Give the elastic beanstalk environment access to the S3 bucket. This link may provide some useful information: https://aws.amazon.com/premiumsupport/knowledge-center/elastic-beanstalk-s3-bucket-instance/ -9. Deploy the application +10. Deploy the application ``` $ eb deploy $EB_ENV ``` -10. Open the application in a browser +11. Open the application in a browser ``` $ eb open $EB_ENV