Deployment Guide
As a user of the PSI system, you can choose to use New Public's instance of PSI, share a partner's instance of PSI (particulaly for partners in your home market you wish to share conversations with), or deploy to your own instance.
Deploy your own instance of the content proxy
If you haven't integrated PSI into your real site yet, then you'll want to deploy the content proxy to rewrite your website to include the psi.js script that sets up sidebar and teaser iframes.
Create and Connect a Firebase Project
- Go to the Firebase Console
- Click
Create a Project - Type in an arbitrary project name (I'm using
deploy-demo-psi-product), and pressContinue - Decline Google Analytics, and press
Create Project - Run
firebase use --addinpsi-productto connect your newly created project id with your checked out code. When asked for an alias sayproduction.
Enable Billing
- Click on the
Sparkicon next to your project name - Follow the prompts to set up the
Blazeplan.
Set Up Authentication
- Open the Firebase Console
- Navigate to your project
- On the left side, click
Build, thenAuthentication, thenGet Started - Click
Googleto start the Google Login setup process - Toggle
Enablein the top right - Enter the product name you want to use in the Google Sign In UI
- Click
Save
Enable Permissions needed for SSO Support
To enable SSO, we need to tell firebase that the standard service account should be able to create custom login tokens.
First enable the IAM Service Account Credentials API:
- Open the IAM Service Account Credentials API settings page
- Select your project selector at the top
- Click the button to enable
Then give your standard service account the taken creation permission: * Goto the IAM Account Management Page * Select your project * Click on the edit/pencil icon for the standard AppEngine default service account. This will be called something like project-name@appspot.gserviceaccount.com * Click "Add Role" * Add "Service Account Token Creator"
Add a custom SSO-Provider
- Open your git-fork and add a custom login provider in client/util/loginproviders.js
- It is important to add the correct silos for your provider
- Add your AuthKeyUrl to server/index.js (currently line 61) using the key you set in loginproviders.js
Initialize the Database
- Run
firebase init database - Choose whichever region makes sense for you. E.g.
europe-west1if you are in Europe, - Decline the friendly offer to overwrite
database.rules.json.
Set up Server Config Files
- Open the Firebase Console
- Navigate to your project
- On the left side, click
Build, thenRealtme database - Click on the link icon next to the database URL to copy it. It will be something like
https://deploy-demo-psi-product-default-rtdb.europe-west1.firebasedatabase.app/. - Create a file called
psi-product/server/production-config.js, with the following contents: (substituting in your database URL)
Set up Client Config Files
- Open the Firebase Console and navigate to your project
- Click
Add AppthenWeb. - Enter an app name (e.g.
Web App) - Enable
Also set up hosting - Click
Register Site - Copy the
firebaseConfigdefinition, and paste it intopsi-product/production-config.js - Add an
exportkeyword in front offirebaseConfig. - It should look something like this:
export const firebaseConfig = { apiKey: "********************************", authDomain: "np-psi-dev.firebaseapp.com", databaseURL: "https://np-psi-dev-default-rtdb.europe-west1.firebasedatabase.app", projectId: "np-psi-dev", storageBucket: "np-psi-dev.appspot.com", messagingSenderId: "768032889623", appId: "1:768032889623:web:634a1604eda03820ab7552" };
Deploy to production
- Build the web client by running
yarn webbuildinclient - Merge the newly built blob into the hosting dir, by running
sh ./update_hosted_files.shinclient - Run
firebase deploy - Test it worked by visiting the component demo at https://deploy-demo-psi-product.web.app/global/componentdemo/demo (replacing
deploy-demo-psi-productwith the name of your firebase project)
Set up Admin rights & Language
To do much beyond look at the component demo, you'll likely want to give yourself admin rights, so you can set up some conversations. We don't have an admin setup UI yet, so sadly you'll need to do it by directly poking the database.
- Open the firebase console
- On the left panel, click
Buildand thenRealtime Database - Click on the
+to add an entry, and then set up the following JSON structure: - Where you can currently set the language to one of
english,french, orgerman. - Repeat this process any silos you want to set up, replacing
globalwith your silo key.