Skip to content

Commit

Permalink
[DUOS-2041][risk=no] Documentation Updates (#1775)
Browse files Browse the repository at this point in the history
* updating docs for running under compose and cypress
  • Loading branch information
rushtong authored Aug 30, 2022
1 parent 6d59aeb commit c9af0f8
Show file tree
Hide file tree
Showing 6 changed files with 380 additions and 644 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ public/config.json


# Server
ca-bundle.crt
server.crt
server.key
server.key
site.conf
111 changes: 111 additions & 0 deletions DEVNOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Local Development

1. We use [node@16](https://github.com/nvm-sh/nvm#installing-and-updating):

```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm install 16
```
2. Install deps:

```
npm install
```

3. Install configs for an environment. This example is for the perf environment, but you can use values from any environment by looking at the deployed configs in https://duos-k8s.dsde-{%ENV%}.broadinstitute.org/config.json where {%ENV%} is any of `dev`, `staging`, `perf`, `alpha`, or `prod`
Remember to set the `env` value appropriately. We use `local` for running via npm, but under docker, we use a real env like `dev`
```
cp config/perf.json public/config.json
```

Ensure that your `/etc/hosts` file has an entry for `local.broadinstitute.org`
```properties
127.0.0.1 local.broadinstitute.org
```

Download cert files from vault (requires vault access - see [DUOS team members](https://github.com/orgs/DataBiosphere/teams/duos) for more specifics):
```shell
vault login -method=github token=$(cat ~/.github-token)
vault read --format=json <vault path>/server.key | jq -r .data.value > server.key
vault read --format=json <vault path>/server.crt | jq -r .data.value > server.crt
vault read --format=json <vault path>/ca-bundle.crt | jq -r .data.chain > ca-bundle.crt
```

Create a `site.conf` file in the project root directory using https://github.com/broadinstitute/terra-helmfile/blob/master/charts/duos/templates/_site.conf.tpl as a model.

Create a local environment file, `.env.local`
```properties
HOST=local.broadinstitute.org
HTTPS=true
SSL_CRT_FILE=server.crt
SSL_KEY_FILE=server.key
```

4. Start development server:

```shell
npm start
```
### Running under Docker

Update your local `docker-compose.yaml` file to mount the preferred `config.json` file in app volumes.
Remember to set the `env` value appropriately in `config.json`. We use `local` for running via npm, but under docker, we use a real env like `dev`

```dockerfile
volumes:
- ./public/config.json:/usr/share/nginx/html/config.json
```

Build and run:

```shell
docker build . -t duos
docker compose up -d
```

# Testing

## Cypress Tests

We use Cypress for all component and integration testing. Each suite
of tests is run separately for all PRs via github actions. Local
testing can be run headless or viewed interactively.

Cypress integration tests run locally require a different `baseUrl` than those
run in Github Actions. Modify your local `cypress.config.js` file so
that the `e2e.baseUrl` looks like this:
```shell
baseUrl: 'https://local.broadinstitute.org:3000/',
```
This is not necessary for component tests.

### Headless
To run cypress integration tests, first start up the app in one terminal
and in another terminal window, spin up the tests headless:

```shell
npm start
npm run cypress:run
```

To run cypress component tests headless:

```shell
npm run cypress:run:component
```

### Interactive
To run cypress integration tests, first start up the app in one terminal
and in another terminal window, spin up the tests for viewing:

```shell
npm start
npm run cypress:open
```

To run cypress component tests in a browser:

```shell
npm run cypress:open:component
```

34 changes: 2 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,5 @@ The Data Use Oversight system ensures that researchers using genomics data honor

![What is DUOS](https://github.com/DataBiosphere/duos-ui/blob/develop/public/images/what_is_duos.svg)

### Developers

1. We use [node@16](https://github.com/nvm-sh/nvm#installing-and-updating):

```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm install 16
```
2. Install deps:

```
npm install
```

3. Install configs for an environment. This example is for the perf environment, but you can use values from any environment by looking at the deployed configs in https://duos-k8s.dsde-{%ENV%}.broadinstitute.org/config.json where {%ENV%} is any of `dev`, `staging`, `perf`, `alpha`, or `prod`

```
cp config/perf.json public/config.json
```
4. Start development server:

```
npm start
```
### Running under Docker

Update your local environment configuration file and mount that to `/usr/share/nginx/html/config.json`

```
docker build . -t duos
docker run -v ${PWD}/path/to/config.json:/usr/share/nginx/html/config.json:ro -p 80:8080 duos:latest
```
### Local Development
See [DEVNOTES.md](DEVNOTES.md) for instructions on setting up an environment for local development.
43 changes: 38 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,52 @@
# This is an example compose file that can be used for local development.
# Modify the config file in `volumes` to point to the desired environment, default id dev.
#
# Ensure that the following configuration files have been created in the correct locations:
# * public/config.json
# * ca-bundle.crt
# * server.crt
# * server.key
# * site.conf
# Ensure that /etc/hosts contains an entry for:
# 127.0.0.1 local.broadinstitute.org
# Build:
# docker build . -t duos
# Run:
# docker-compose up
# docker compose up -d
# Test
# http://localhost:3000/
# https://local.broadinstitute.org/
version: '3.8'
services:
app:
image: duos:latest
container_name: duos
ports:
- 3000:8080
- 8080:8080
volumes:
- ./config/perf.json:/usr/share/nginx/html/config.json
- ./public/config.json:/usr/share/nginx/html/config.json
command: ["nginx", "-g", "daemon off;"]
restart: always

proxy:
image: broadinstitute/openidc-proxy:tcell_3_1_0
container_name: duos-proxy
hostname: local.broadinstitute.org
links:
- app:app
ports:
- 80:8080
- 443:443
volumes:
- ./server.crt:/etc/ssl/certs/server.crt:ro
- ./server.key:/etc/ssl/private/server.key:ro
- ./ca-bundle.crt:/etc/ssl/certs/ca-bundle.crt:ro
- ./site.conf:/etc/apache2/sites-available/site.conf:ro
environment:
AUTH_TYPE: AuthType None
LOG_LEVEL: warn
OIDC_CLAIM: Require all granted
PROXY_PATH: /
PROXY_URL: http://app:8080/
SERVER_NAME: local.broadinstitute.org
SERVER_NAME_INT: local.broadinstitute.org
ENABLE_TCELL: 'no'
restart: always
Loading

0 comments on commit c9af0f8

Please sign in to comment.