Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 20 additions & 35 deletions docs/GETTING-STARTED.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
# Running the application

## Npm tasks desciption
Npm tasks are run via
```bash
npm run <TASK>
npm run <TASK> -- RCTMAKE_ADDITIONAL_ARGUMENTS
```
Most tasks are `rctmake` wrappers.

### Within docker:
1. `prune` - removes each container related to this project
## Starting with docker
1. `dev` - main task for running application in dev mode. The task prunes, builds and runs containers, one for the database and one for the application. Changes in the local repo force the application restart (see nodemon and the `start:dev` script, see also `rctmake` option `--target-modifier`). You can run multiple instances of application in dev mode simultaneously, see `rctmake` option `--subtarget` and `--rct-http-port`.
2. `idev` - run node console with imported application instance (not running), should be run inside container see `app:battach`

2. `dev` - prune, build and run containers, one for the database and one for the application. Changes in the local repo force the application restart on docker (see nodemon and the `start:dev` script).
Dev does not deploy the new database, it only clears it. In case of any changes in the database or docker images, the use of `dev:prune` is advised.
3. `dev:up` - up stopped (previously) built containers (no data in db is erased)
4. `dev:up-r <DUMP_NAME>` - as dev:up but also restore specified dump (existing in `<ProjectDir>/database/cache/dumps`), see the `dump:list` task
5. `app:attach` - attach to the application container console
6. `db:check` - export the current pgmodeler design as the database definition file, delete the database container and rebuild it with the new design. Application container will be deleted as well.
7. `db:attach` - run psql as postgres (connected to RCT database) on database container
8. `db:clean` - clean database in the running database docker

### Database dumps managing, dumps are stored in `<ProjectDir>/database/cache/dumps`
9. `dump:make <DUMP_NAME>` - make a data dump and store it under the specified name
10. `dump:list` - list all the dumps stored in local cache
11. `dump:restore <DUMP_NAME>` - clean the db and restore the data from the specified dump file
12. `dump:remove <DUMP_NAME>` - remove the dump file from cache

### Testing
13. `eslint` - static analysis, results in `<ProjectDir>/reports/static/static-analyzis.html`
14. `reports:show` - open reports
15. `docker:test` - run static analysis and codecov on docker containers, results are available in `<ProjectDir>/reports/`

### Starting locally:
1. `start:dev:local` - run the RCT application locally, by default it fetches env vars from `<ProjectDir>/docker/env_file-dev` with exception that RCT_DB_HOST env var is substituted to localhost. If you want to make other substitutions, specify them as follows (bash) before the aplication start: `(export FOO=bar; npm run start:dev:local)`
2. `deploy:db:local` - deploy the database locally with the use of `<ProjectDir>/database/setup-db.sh` script. It uses the same env as the upper task and follows the same env vars substitution logic.
## Starting locally
1. `start:dev:local` - run the RCT application locally, by default it fetches env vars from `<ProjectDir>/docker/dev.env` with exception that `RCT_DB_HOST` env var is substituted to localhost. If you want to make other substitutions, specify them as follows (bash) before the aplication start: `(export FOO=bar; npm run start:dev:local)`
2. `deploy:db:local` - deploy the database locally with the use of `<ProjectDir>/database/setup-db.sh` script. It uses the same env as the upper task and follows the same env vars substitution logic.

## Using grid certificates
Grid certificates need to be located in `<ProjectDir>/security/`. The certificate used by the application has to be named (TMP *TODO filename convention*) `rct-alimonitor-cert.p12`. It is also required to set `ALIMONITOR_PASSPHRASE` env var which holds the passphrase to that certificate.

## Reaching CERN network
1. Default behaviour of the application running on docker (var `RUNNING_ENV` is set to `DOCKER`) is to use ssh proxy `socks://172.200.200.1:12345` opened on a host, so you need to locally open ssh socket via command:
1. By default, the application running on docker (var `RUNNING_ENV` is set to `DOCKER`) doesn't use proxy. Crucial functionalities (e.g. data synchronization) require access to the CERN network. If the host is not directly connected, a proxy configuration is needed. You can point proxy via env var `CERN_SOCKS` with value 'true' what will be evaluated to `socks://172.200.200.1:12345`, for which you should open ssh socket locally via command:
```bash
ssh -D 172.200.200.1:12345 <user>@<host>
```
Expand All @@ -50,17 +31,21 @@ or using script which opens defualt proxy (the same as above one)
```bash
ssh -D localhost:12345 <user>@<host>
```
then save the address of the socket you've opened in CERN_SOCKS env var e.g.
The address of the socket you've opened should be saved in CERN_SOCKS env var, e.g.:
```bash
export CERN_SOCKS='socks://localhost:12345'
```
3. If you want to not use proxy set CERN_SOCKS to false:
3. If you want to use proxy, set `CERN_SOCKS` to true:
```bash
export CERN_SOCKS='false'
export CERN_SOCKS='true'
```

## Database
For the sake of using the application with mock data and managing mock data changes, the `mockData.ipynb` notebook has been created. Make sure you meet the requirements:
## Database dumps
Dumps are stored in `<ProjectDir>/database/cache/dumps`
see `rctmake` help


1. python > 3.7
2. jupyter notebook with nbconverter used to transform `database/mock/mockData.ipynb` to python script, also required for git hook if changing this notebook
## Testing
1. `test` - main testing task, run static analysis and codecov on docker containers, results are available in `<ProjectDir>/reports/`
2. `eslint` - static analysis, results in `<ProjectDir>/reports/static/static-analyzis.html`
3. `reports:show` - open reports, static analysis and codecov in browser
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@
"start:dev:local": "(export RCT_DB_HOST=${RCT_DB_HOST:-localhost}; bash -c 'set -o allexport && ls && source ./docker/dev.env && set +o allexport && npm run start:dev')",
"deploy:db:local": "./database/setup-db.sh --env ./docker/dev.env",
"dev": "./rctmake prune,db:export,run,app:attach,stop --target dev",
"cdev": "export RCT_DEV_USE_CACHE=true; ./rctmake prune,db:export,run,app:attach,stop",
"idev": "node -e \"app = require('./app/application.js'); const { databaseManager: dbm } = app\" -i",
"node-dev-env": "(export RCT_DB_HOST=$(docker inspect o2rct_database-dev -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'); bash -c 'set -o allexport && ls && source ./docker/dev.env && set +o allexport && node')",
"dev:up": "./rctmake run[up],app:attach",
"dev:up-re": "./rctmake run[up],dump:restore,app:attach -F ",
"test": "./rctmake prune,run --target test",
"prune": "./rctmake prune",
"app:attach": "./rctmake app:attach",
Expand Down