bbc / digital-paper-edit-firebase

Firebase version of DPE
https://digital-paper-edit-dev.web.app/
Other
8 stars 5 forks source link

Create dev (test) deployment environment on GCP #198

Closed tamsingreen closed 3 years ago

tamsingreen commented 3 years ago

Context

We want to have separate environments for dev and prod. Everything is currently on Dev.

Acceptance Criteria

Make an equivalent for Live.

Notes

The convention for test and live environment is "dev" and "prod" in GCP. In .firebaserc, you'll see:

  "projects": {
    "default": "newslabs-dev-aa20",
    "dev": "newslabs-dev-aa20",
    "prod": "newslabs-prod-1a3c"
  }
}

It's safe to assume none of the below services are setup for prod:

We would need to manually create these assets, with a very similar layout as the dev environment.

The only setup for prod there is is that it's in package.json. The way this works is that using your logged in Firebase tools, it knows the projects that you have - dev and prod. If you run firebase deploy -P prod --only functions - this means it's specifying the prod project you already have setup (in .firebaserc) and deploys only Functions to that project.

Functions

In functions, GCP stores runtime configurations. This is where the information of assets (i.e. storage) are. You can run firebase -P dev config:get or something like that to get the runtime config.

"storage": {
    "bucket": "dev-digital-paper-edit"
  },

Hosting and others

In hosting and other spaces, you would need to look at firebase.json root directory to understand how the configuration is setup.

"hosting": {
    "site": "digital-paper-edit-dev",

You can use the firebase deploy -P prod --only x,y,z to deploy for any service.

React

The way the React App knows where to look for the things, is also in the code under firebase.js. This is where the .env is loaded with necessary information to get access to the relevant project:

...
REACT_APP_API_KEY=
REACT_APP_AUTH_DOMAIN=
REACT_APP_DATABASE_URL=
REACT_APP_PROJECT_ID=digital-paper-edit
REACT_APP_STORAGE_BUCKET=
REACT_APP_MESSAGING_SENDER_ID=
REACT_APP_APP_ID=
REACT_APP_MEASUREMENT_ID=
allishultes commented 3 years ago

Stand down: see https://newslabs.slack.com/archives/C07B5URHP/p1619106881041100 (full convo in dev channel). Possibly not relevant for this ticket (see https://github.com/bbc/digital-paper-edit-infrastructure/issues/21).

If we can get one of the Firebase domains to work(https://digital-paper-edit-prod.web.app/#/), I think we can consider this done. There seems to be an issue with either rules or permissions on GCP storage; to replicate, try to upload a transcript to the url above.

Screenshot 2021-04-22 at 17 46 48
tamsingreen commented 3 years ago

Is there anything to review in the repo (config etc) for this or does it all live in Firebase?

allishultes commented 3 years ago

Is there anything to review in the repo (config etc) for this or does it all live in Firebase?

I think it all lives in Firebase. I've added the runtime config to our AWS KMS parameter store; it's not used there, but is a secure place to store it and it's where the test lives. I'm not sure about the analytics setup? But everything else has been done, unless the documentation isn't clear.

tamsingreen commented 3 years ago

I'm just raising a PR for the prod hosting config - I think that's all though!