Skip to content

Commit

Permalink
add deployment configuration and documentation for staging env (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
macfarlandian committed Jan 11, 2021
1 parent ca03f50 commit 3a6397c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ In addition, there are some Yarn scripts defined in the root package as a conven

`yarn test` - runs the tests for all packages in a single command. (The output this produces is pretty messy at the moment but it can be useful for editor integration)

#### Notes and quirks

The monorepo tooling in this project can be a little rough at times. Any bits of secret knowledge that will help with troubleshooting and configuration should be collected here.

- **Jest versions must match across projects**: We are pinned to an older version of Jest by Create React App. Packages that install Jest independently of CRA (e.g., the API server) need to match that version or tests for all packages will fail with an error about finding multiple versions of Jest. (This happens because Yarn hoists most packages to the root.)

### Code editor integration

Your code editor may need some additional configuration to properly integrate with this monorepo setup. While not exhaustive, these are some tips we have found useful for ourselves:
Expand Down
1 change: 0 additions & 1 deletion spotlight-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"morgan": "^1.10.0"
},
"devDependencies": {
"//": "jest version needs to match react-scripts dep in other packages",
"jest": "24.9.0",
"lint-staged": ">=10",
"n-readlines": "^1.0.1",
Expand Down
5 changes: 5 additions & 0 deletions spotlight-client/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"staging": "spotlight-staging-f0154"
}
}
16 changes: 15 additions & 1 deletion spotlight-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,21 @@ There is no per-view authentication; enabling auth (via environment variable, as

## Deploys

Not yet implemented! Instructions will be found here once a process is in place.
This app can currently only be run locally or in a staging environment. Information about the production environment will be added here once it is provisioned.

### Pre-requisites

This React application is deployed to Firebase. To have deploy access, you need to be an admin on the Recidiviz Firebase account.

Once you have the required permissions, you can set up your environment for deploys by following [these instructions](https://firebase.google.com/docs/cli?install-cli-mac-linux). Specifically, follow the steps entitled "Install the Firebase CLI" and "Log in and test the Firebase CLI."

### Deploying to Staging

To generate a staging build, invoke the following yarn script: `yarn build-staging`. This will include the appropriate environment variables from `.env.development`. Each time this is run, the `/build` directory will be wiped clean.

You should then test this locally by running `firebase serve`: it will run the staging build locally, pointed to the staging API backend. (Note that this means you will have to deploy the backend to staging first if your build requires unreleased backend features.)

When you're satisfied, deploy the frontend to staging with `firebase deploy -P staging`. Test vigorously on staging before deploying to production.

## Available Scripts

Expand Down
16 changes: 16 additions & 0 deletions spotlight-client/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
2 changes: 2 additions & 0 deletions spotlight-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"license": "GNU General Public License v3",
"scripts": {
"build": "react-scripts build",
"build-staging": "env-cmd -f .env.development react-scripts build",
"dev": "react-scripts start",
"eject": "react-scripts eject",
"lint": "tsc && eslint '**/*.{js,ts,tsx}'",
Expand Down Expand Up @@ -56,6 +57,7 @@
"@types/node": "^12.0.0",
"@typescript-eslint/eslint-plugin": "^4.4.0",
"@typescript-eslint/parser": "^4.4.0",
"env-cmd": "^10.1.0",
"eslint-import-resolver-typescript": "^2.3.0",
"jest-environment-jsdom-sixteen": "^1.0.3",
"lint-staged": ">=10"
Expand Down

0 comments on commit 3a6397c

Please sign in to comment.