When initializing a new instance of the C&T Firebase project, make sure that the functions/config/admins.js
file contains the emails of administrators you want to initialize.
-
Install Firebase CLI
npm install -g firebase-tools
-
Login to Firebase CLI
firebase login
-
Inside root of repo, set Firebase CLI to use appropriate project:
firebase use <project id>
Eg. For current staging environment, use
candt-admin-dev
as project id
Local environment setup:
-
Get Google Application Credentials JSON file and set
GOOGLE_APPLICATION_CREDENTIALS
path variable to point to file (https://cloud.google.com/docs/authentication/getting-started)GOOGLE_APPLICATION_CREDENTIALS="<path to json file>.json"
-
Configure local enviornment config variables inside
.runtimeconfig.json
file in root of repoTo export current config from Firebase, run in root of repo:
firebase functions:config:get > .runtimeconfig.json
-
Run
npm install
inside of functions directory -
From root directory, run
firebase emulators:start
-
Configure remote env vars (only if updates are required)
- Get latest remote env vars
firebase functions:config:get > env.json
- remove outer
env
object (field and brackets) - edit as required
- reset env vars
firebase functions:config:unset env && firebase functions:config:set env="$(cat env.json)"
(note the double quotes around the value)
- Get latest remote env vars
-
From the root of the repo, run the following command to deploy to current project:
firebase deploy --only functions
- Firebase CLI cheatsheet
- Adding environment variables to firebase: https://firebase.google.com/docs/functions/config-env
- Getting Google Application Credentials file: https://cloud.google.com/docs/authentication/getting-started