diff --git a/README.md b/README.md index eca5bab9a3f2ecffe9b7ba2ccceaa25ba42ba743..db946c3a0086512552baf5e95666e56475718f96 100644 --- a/README.md +++ b/README.md @@ -21,86 +21,93 @@ end # Getting started Each folder contains one of the components of -## Login in the docker registry +## Local Deployment + +### Login in the docker registry If you are not already logged in, you need to authenticate to the Container Registry by using your GitLab username and password. If you have Two-Factor Authentication enabled, use a Personal Access Token instead of a password. ```bash docker login registry.digitallearning.gmbh ``` -## Create Docker Network +### Create Docker network Different containers communicate via a Docker network `web`, which must be created before Docker compose files are executed. ```bash docker network create web ``` -## LRS / MongoDB -First we need a database or LRS to store the xAPI Statements. In a local setup, you can use the docker container in the mongodb folder. -Rename or copy the sample configuration. Please change all passwords in the configuration file. +### Create private/public keys and .env + +Please change all passwords in the configuration file and leave the passphrase empty. ```bash -cd mongodb +cd single-compose +ssh-keygen -b 4096 -f id_rsa cp .env.sample .env ``` -Now you can start the mongodb with the following command + +### Start containers + ```bash docker compose up -d ``` -Please check that the database is created: +Please check whether all services started successfully. ```bash docker compose ps ``` +After that you should be able to visit http://localhost:8004/ and see the rights engine. -## Rights engine -First create some jwt keys with the following command: +### Migrate rights-engine database (only required once after first start) ```bash -cd rights-engine -ssh-keygen -t rsa -b 4096 -m PEM -f id_rsa -openssl rsa -in id_rsa -pubout -outform PEM -out id_rsa.pub +docker compose exec -it rights-engine sh -c 'python3 manage.py sqlflush | sed s/TRUNCATE/DROP\ TABLE\ IF\ EXISTS/g | python3 manage.py dbshell && echo DROP\ TABLE\ IF\ EXISTS\ django_migrations\; | python3 manage.py dbshell && python3 manage.py migrate && python3 manage.py loaddata fixtures/initial_db.json' ``` -Leave the passphrase empty. -Rename or copy the sample configuration. Please change all passwords in the configuration file. -```bash -cp .env.sample .env -``` +### Migrate analytics-engine database (only required once after first start) -At the first run, create the database with the following command: ```bash -docker compose exec -it rights-engine sh -c 'python3 manage.py sqlflush | sed s/TRUNCATE/DROP\ TABLE\ IF\ EXISTS/g | python3 manage.py dbshell && echo DROP\ TABLE\ IF\ EXISTS\ django_migrations\; | python3 manage.py dbshell && python3 manage.py migrate && python3 manage.py loaddata fixtures/initial_db.json' +docker compose exec -it scheduler sh -c 'scheduler create-db' ``` -Now you can start the rights engine with the following command -```bash -docker compose up -d +### Adding analytics engine jobs + +Analytics engines jobs are configured via yml files and read from the `configuration` directory, which is a volume. + +Example configuration file `configuration/h5p_engines.yml` +```yml +h5p_statements_count_engine: + crontab: "*/1 * * * *" + repo: "https://scheduler:glpat-MsDsrHMH-k3-DzEfNRgk@gitlab.digitallearning.gmbh/polaris/engines/dummy-engine.git" + analytics_token: "b6a4ec069ef9f688e781161d46c2a85c14a761a4eaf0074099656c7de44a65d9" ``` -Please check that all services are started: +Update analytics engine scheduler ```bash -docker compose ps +docker compose exec -it scheduler sh -c 'scheduler read-configs' ``` -After that you should be able to visit http://localhost:80/ and see the rights engine. +### Create visualization token -## Analytics engine -Rename or copy the sample configuration. Please change all passwords in the configuration file. ```bash -cd analytics-engine -cp .env.sample .env +curl -X POST http://localhost:8004/api/v1/provider/visualization-tokens/create --data '{"engines": ["count_h5p_statements", "count_moodle_statements"]}' -H "Content-Type: application/json" ``` -At the first run, you need to seed the database with the following command -```bash -docker compose down && docker compose up -d && sleep 30 && docker compose exec -it scheduler sh -c 'scheduler create-db' && docker compose exec -it scheduler sh -c 'scheduler read-configs' +Returns JWT Token for dashboard ``` - -Now you can start the analytics engine with the following command -```bash -docker compose up -d +{"token":[JWT_TOKEN]"} ``` +### Start dashboard + +1. Clone  + - ```bash + cd dashboard-example + npm install + ``` +2. Update `TOKEN` in `dashboard-example/src/js/app.js` +3. Run `npm run dev` + ## Update Docker Images ```bash docker compose pull