Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create dev (test) deployment environment on GCP #198

Closed
5 tasks done
tamsingreen opened this issue Apr 13, 2021 · 4 comments · Fixed by #223
Closed
5 tasks done

Create dev (test) deployment environment on GCP #198

tamsingreen opened this issue Apr 13, 2021 · 4 comments · Fixed by #223
Assignees
Labels
medium okr This directly relates to an OKR

Comments

@tamsingreen
Copy link
Contributor

tamsingreen commented Apr 13, 2021

Context

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

Acceptance Criteria

Make an equivalent for Live.

  • Firebase is setup in prod (newslabs-prod-1a3c) project: Firestore, Security rules, Storage, Auth, Hosting, Functions. Make sure to deploy to the same distribution area, and replace any occurrence of "dev" in a variable with "prod".
  • Have a single admin user setup in Auth
  • Environment variables are uploaded to AWS (runtime config and env) as well as set in GCP.
  • Update documents (README, etc.)
  • Analytics setup with https://newslabs-analytics.tools.bbc.co.uk/

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:

  • Hosting
  • Functions
  • Storage
  • Firestore Rules
  • Firestore
  • Analytics

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
Copy link
Contributor

allishultes commented Apr 22, 2021

Stand down: see https://newslabs.slack.com/archives/C07B5URHP/p1619106881041100 (full convo in dev channel). Possibly not relevant for this ticket (see bbc/digital-paper-edit-infrastructure#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

@allishultes allishultes mentioned this issue Apr 23, 2021
3 tasks
allishultes added a commit that referenced this issue Apr 23, 2021
* Bump react-dev-utils from 11.0.3 to 11.0.4 (#193)

Bumps [react-dev-utils](https://github.com/facebook/create-react-app/tree/HEAD/packages/react-dev-utils) from 11.0.3 to 11.0.4.
- [Release notes](https://github.com/facebook/create-react-app/releases)
- [Changelog](https://github.com/facebook/create-react-app/blob/master/CHANGELOG-1.x.md)
- [Commits](https://github.com/facebook/create-react-app/commits/HEAD/packages/react-dev-utils)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Deal with unhandled exceptions in Admin view (#204)

* Deal with unhandled exceptions in Admin view.

[fix] add default params to Transcripts view. Unsure when the bug was introduced.
Also had to change the admin role - not sure when this was changed either.

* [fix] Actually should have a better error message

* [fix] Better message

* refactor(env): #198 Add logic to handle both test and live envs at build

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eimi Okuno <[email protected]>
@tamsingreen tamsingreen linked a pull request Apr 27, 2021 that will close this issue
@tamsingreen tamsingreen removed a link to a pull request Apr 27, 2021
@tamsingreen
Copy link
Contributor Author

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

@allishultes
Copy link
Contributor

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
Copy link
Contributor Author

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

@tamsingreen tamsingreen linked a pull request Apr 28, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium okr This directly relates to an OKR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants