-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DUOS-2041][risk=no] Documentation Updates (#1775)
* updating docs for running under compose and cypress
- Loading branch information
Showing
6 changed files
with
380 additions
and
644 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,5 +39,7 @@ public/config.json | |
|
||
|
||
# Server | ||
ca-bundle.crt | ||
server.crt | ||
server.key | ||
server.key | ||
site.conf |
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,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 | ||
``` | ||
|
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 |
---|---|---|
@@ -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 |
Oops, something went wrong.