-
Notifications
You must be signed in to change notification settings - Fork 1
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
Documentation: Add documentation for the staging and production instance #317
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
835ca23
Add documentation for staging and prod
jennyziyi-xu 85fc175
Merge remote-tracking branch 'origin/develop' into jenny/documentation
jennyziyi-xu d70cdbd
Modify README.md
jennyziyi-xu 0690922
code formatting
jennyziyi-xu 77e0dd3
Grammatical fixes
jennyziyi-xu d055e0a
Merge remote-tracking branch 'origin/develop' into jenny/documentation
jennyziyi-xu c32cf7a
Add Keycloak related info
jennyziyi-xu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Local Development Environment | ||
|
||
## Front End | ||
|
||
The front end is a React.js SPA bootstrapped with [create-react-app](https://github.com/facebook/create-react-app) and written in [Typescript](https://www.typescriptlang.org/). [Styled-components](https://styled-components.com/docs) is used for theming and styling. Additional component tooling is provided by [storybook](https://storybook.js.org/). | ||
|
||
### Building and editing the front end code | ||
|
||
- from the root project directory, copy the sample `.env` file and enter the appropriate values: | ||
- ```bash | ||
cp .env.sample .env | ||
``` | ||
- if this is your first time bringing up the app, install the dependencies: | ||
- ```bash | ||
docker-compose run --rm react yarn install | ||
``` | ||
- bring up the react app using [docker-compose](https://docs.docker.com/compose/): | ||
|
||
- ```bash | ||
docker-compose up react | ||
``` | ||
- note that this will enable hot reloading. | ||
|
||
- (optional) start the storybook server: | ||
- ```bash | ||
docker-compose exec -i react yarn storybook | ||
``` | ||
|
||
## Server | ||
|
||
The back end is a node.js server built with [express](https://expressjs.com/), [Typescript](https://www.typescriptlang.org/), and [graphql](https://graphql.org/). | ||
|
||
### Building and editing the back end code | ||
|
||
- make sure the `.env` file exists (see above) | ||
- if this is your first time bringing up the app, install the dependencies: | ||
- ```bash | ||
docker-compose run --rm server yarn install | ||
``` | ||
- bring up the server using [docker-compose](https://docs.docker.com/compose/): | ||
|
||
- ```bash | ||
docker-compose up server | ||
``` | ||
- note that this will recompile the typescript and restart the server when changes are detected. | ||
|
||
- to run the tests: | ||
- ```bash | ||
docker-compose run --rm server yarn test | ||
``` | ||
|
||
### Connecting to Phenotips | ||
|
||
The Phenotips staging instance's API endpoint is specified by the `G4RD_URL` env var. The OSMP server uses the OSMP machine account specified by `G4RD_USERNAME` and `G4RD_PASSWORD` to authenticate to the endpoint. The Phenotips staging site can be accessed in the browser by navigating to the URL specified by the `G4RD_URL` env var, using the OSMP machine account. | ||
Phenotips API documentation can be found [here](https://help.phenotips.com/hc/en-us/articles/360048543632-Variant-Store-Add-on-REST-API). | ||
### Building the remote test server | ||
Apart from Phenotips, another data source for the staging instance is a Node/Express server that queries a MySQL database that has been populated wtih variants from the STAGER application database. | ||
- make sure the `.env` file exists (see above) | ||
- if this is your first time bringing up the app, install the dependencies: | ||
- ```bash | ||
docker-compose run --rm test-node yarn install | ||
``` | ||
- bring up the server using [docker-compose](https://docs.docker.com/compose/): | ||
- ```bash | ||
docker-compose up test-node | ||
``` | ||
- to populate the MySQL database with variants from STAGER, download this [script](https://sickkidsca.sharepoint.com/:u:/r/sites/thecenterforcomputationalmedicineworkspace/Shared%20Documents/SSMP/data/stager-local-20210716.sql?csf=1&web=1&e=fVzHIB) and run the script using one of these two options: | ||
- MySQLWorkbench | ||
- ```bash | ||
docker exec -i <stager-mysql-container-name> mysql -u <env.TEST_DATA_DB_USER> --password="<env.TEST_DATA_DB_PASSWORD>" <env.TEST_DATA_DB> < <filepath>.sql | ||
``` | ||
where the `.sql` script is on the host machine. | ||
## Keycloak | ||
The app uses [keycloak](https://www.keycloak.org/) as an identity provider and identity broker. Essentially, keycloak stores all user information and the app is a keycloak client. The implementation is currently in its earliest phases and documentation will be updated as the project evolves. | ||
In the dev environment, the app uses keycloak's default h2 database for storage, though in production we'll want to use MySQL or Postgres. To set up the app client and a test user, you can use the following command on your host machine with the keycloak container running: | ||
```bash | ||
docker-compose exec keycloak /usr/local/bin/bootstrap-keycloak.sh | ||
``` | ||
The keycloak admin portal can be accessed in the browser by navigating to localhost and the port specified by the `KEYCLOAK_PORT` env var, e.g., `localhost:9821` | ||
## Mongo | ||
gnomAD annotations are performed on-the-fly using MongoDB. The staging VM and production VM are connected to the MongoDB instance in the CHEO-RI tenancy. Since dev VMs are not in the CHEO-RI tenancy, they cannot connect to the MongoDB instance in the CHEO-RI tenancy. Instead, in local development, we can connect to [mongodb.ccm.sickkids.ca](mongodb.ccm.sickkids.ca) which currently only supports GRCh37 annotations and a small subset of GRCh38 annotations. | ||
Annotations were imported into mongo using the following command. Note that that the headers should not be included in the csv and the order of the fields passed to the `fields` argument should match the order of the fields in the csv. | ||
```bash | ||
mongoimport --collection=annotations --type=csv \ | ||
--columnsHaveTypes \ | ||
--fields="pos.int32(),ref.string(),alt.string(),chrom.string(),nhomalt.int32(),an.int32(),af.double(),assembly.string()" \ | ||
--file=<filename>.csv \ | ||
--uri=mongodb://<env.MONGO_INITDB_ROOT_USERNAME>:<env.MONGO_INITDB_ROOT_PASSWORD>@mongo/<env.MONGO_INITDB_DATABASE>?authSource=admin | ||
``` | ||
Then make sure to create the following indexes to optimize the query: | ||
``` | ||
db.annotations.createIndexes([ {"pos": 1}, {"assembly":1}, {"alt": 1, "chrom": 1, "pos": 1, "ref": 1 } ]) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Production | ||
|
||
OSMP is deployed via Compose at [https://osmp.genomics4rd.ca](https://osmp.genomics4rd.ca). The key differences between the staging and production are the removal of the test node and increased memory and CPU resource allocations for the `server` container. The OSMP production instance is connected to the [production instance of G4RD Phenotips](https://phenotips.genomics4rd.ca). Similar to the staging stack, to deploy the frontend, compiled static bundles are uploaded to a designated MinIO bucket. The routing between the frontend and backend is handled by the HAProxy reverse proxy. | ||
|
||
## Continuous deployment through Github Actions | ||
|
||
On each commit to the `production` branch, if the changes affect the backend, a Github Actions workflow [Build, test, and deploy backend to production](https://github.com/ccmbioinfo/osmp/blob/develop/.github/workflows/node-prod.yml) is run. After the Docker image build and test stages pass, we move to the deployment stage. This stage runs on a self-hosted Actions runner that is networked with the production host, and deploys the backend to the production host. | ||
|
||
If the changes affect the frontend, a different workflow [Build react app and deploy to production](https://github.com/ccmbioinfo/osmp/blob/develop/.github/workflows/react-prod.yml) builds the frontend, incorporating environment-specific configurations as needed, and uploads the compiled static bundles to a designated S3 (MinIO) bucket. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,9 @@ | ||||||
# Staging | ||||||
|
||||||
OSMP is deployed via Compose at [https://osmp.ccmdev.ca/](https://osmp.ccmdev.ca/). For G4RD data source, the OSMP staging instance is connected to the [staging instance of G4RD Phenotips](https://osmp.ccmdev.ca/). To deploy the frontend, compiled static bundles are uploaded to a designated MinIO bucket. The routing between the frontend and backend is handled by the HAProxy reverse proxy. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
## Continuous deployment through Github Actions | ||||||
|
||||||
On each commit to the `develop` branch, if the changes affect the backend, a Github Actions workflow [Build, test, and deploy backend to staging](https://github.com/ccmbioinfo/osmp/blob/develop/.github/workflows/node.yml) is run. After the Docker image build and test stages pass, we move to the deployment stage. This stage runs on a self-hosted Actions runner that is networked with the staging host, and deploys the backend to the staging host. | ||||||
|
||||||
If the changes affect the frontend, a different workflow [Build react app and deploy to staging](https://github.com/ccmbioinfo/osmp/blob/develop/.github/workflows/react.yml) builds the frontend, incorporating environment-specific configurations as needed, and uploads the compiled static bundles to a designated S3 (MinIO) bucket. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.