Skip to content

Commit

Permalink
postgresql support (#79)
Browse files Browse the repository at this point in the history
* postgresql support

* docs
  • Loading branch information
grzanka authored Nov 16, 2023
1 parent 529364d commit b9c6e8b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
12 changes: 6 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ git clone --recurse-submodules https://github.com/yaptide/ui.git

Note `--recurse-submodules`. This is needed as the converter package is included as a submodule in both repositories.

Local deployment allows only for job execution on Celery worker. To be able to submit jobs to the HPC cluster, one needs to have access to the
Local deployment allows only for job execution on Celery worker. To be able to submit jobs to the HPC cluster, one needs to have access to the

## Deploying backend

Lets start with deploying backend using docker compose. This should take couple of minutes to complete.
Lets start with deploying backend using docker compose. This should take couple of minutes to complete.

First go to the directory where backend was cloned:
```bash
Expand All @@ -51,7 +51,7 @@ The `yaptide_nginx` container serves as a proxy and is exposing the REST API on

## Deploying frontend

In a similar way as for backend, the frontend can be deployed using docker compose. This should take couple of minutes to complete.
In a similar way as for backend, the frontend can be deployed using docker compose. This should take couple of minutes to complete.

First go to the directory where frontend was cloned:
```bash
Expand All @@ -76,10 +76,10 @@ Frontend is configured to use the backend REST API exposed on port 5000, using p
At this point there is no single user in the database, so we need to create one. This can be done using the following command:

```bash
docker exec yaptide_flask python3 yaptide/admin/db_manage.py add-user admin --password password
docker exec yaptide_flask ./yaptide/admin/db_manage.py add-user admin --password password
```

## Running first simulation

Now we are ready to run our first simulation. First we need to login to the frontend. Open your browser and navigate to [http://localhost:80](http://localhost:80) or [https://localhost:443](https://localhost:443).
Login with the credentials created in the previous step.
Now we are ready to run our first simulation. First we need to login to the frontend. Open your browser and navigate to [http://localhost:80](http://localhost:80) or [https://localhost:443](https://localhost:443).
Login with the credentials created in the previous step.
8 changes: 4 additions & 4 deletions docs/maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note the `--build` flag. It is needed to rebuild the containers, as the source c

## Storage volume

The yaptide backend uses the docker volume named `yaptide_data` to store the data. It hosts SQLite database with following information:
The yaptide backend uses the docker volume named `yaptide_data` to store the data. It hosts PostgreSQL data with following information:

* user accounts
* data related to simulations:
Expand All @@ -55,11 +55,11 @@ The SSL certificates are used to secure the communication for two cases:
* between the user client and the machine serving the UI
* between the user client and the machine serving the backend

Frontend uses Nginx to serve statically generated HTML, CSS and JavaScript files.
Frontend uses Nginx to serve statically generated HTML, CSS and JavaScript files.
Backend uses Nginx as a proxy to forward requests to the backend server.
Both Nginx instances are configured to use SSL certificates.

By default the self-signed certificates are used (usually not trusted by the browser).
By default the self-signed certificates are used (usually not trusted by the browser).
They are generated automatically when the containers are started for the first time.

To replace self-signed certificates with your own, stop the containers and replace the files according to the following recipe.
Expand Down Expand Up @@ -106,4 +106,4 @@ Restart the container:

```bash
docker restart yaptide_nginx
```
```
2 changes: 2 additions & 0 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mode: deploy

backend_password: "{{ lookup('ansible.builtin.password', 'roles/backend/files/password length=25 chars=ascii_letters,digits') }}"
backend_postgres_user: "{{ lookup('ansible.builtin.password', 'roles/backend/files/postgres_user length=25 chars=ascii_letters,digits') }}"
backend_postgres_password: "{{ lookup('ansible.builtin.password', 'roles/backend/files/postgres_password length=25 chars=ascii_letters,digits') }}"
4 changes: 4 additions & 0 deletions roles/backend/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ backend_keycloak_realm: ""
backend_ssl_crt: "server.crt"
backend_ssl_key: "server.key"

backend_postgres_db: "yaptide"
backend_postgres_user: "yaptide"
backend_postgres_password: "yaptide"

ansible_become: false

Check warning on line 19 in roles/backend/defaults/main.yml

View workflow job for this annotation

GitHub Actions / linter (3.9)

var-naming[no-role-prefix]

Variables names from within roles should use backend_ as a prefix. (vars: ansible_become)

Check warning on line 19 in roles/backend/defaults/main.yml

View workflow job for this annotation

GitHub Actions / linter (3.10)

var-naming[no-role-prefix]

Variables names from within roles should use backend_ as a prefix. (vars: ansible_become)

Check warning on line 19 in roles/backend/defaults/main.yml

View workflow job for this annotation

GitHub Actions / linter (3.11)

var-naming[no-role-prefix]

Variables names from within roles should use backend_ as a prefix. (vars: ansible_become)
6 changes: 5 additions & 1 deletion roles/backend/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
{% if lookup('file', './.env', errors='ignore') is defined %}
{{ lookup('file', './.env', errors='ignore') }}
{% endif %}
POSTGRES_DB = {{ backend_postgres_db }}
POSTGRES_USER = {{ backend_postgres_user }}
POSTGRES_PASSWORD = {{ backend_postgres_password }}
# https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_module.html
Expand Down Expand Up @@ -75,12 +78,13 @@
command: 'python3 yaptide/admin/db_manage.py add-user admin --password {{ backend_password }}'
chdir: /usr/local/app/
register: backend_add_user_output
retries: 5
delay: 5

- name: Print output of add-user command
ansible.builtin.debug:
msg: '{{ backend_add_user_output.stdout_lines }}'


- name: Insert first cluster into database
community.docker.docker_container_exec:
container: yaptide_flask
Expand Down
4 changes: 2 additions & 2 deletions yap_dev_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ backend_keycloak_base_url: 'https://sso.pre.plgrid.pl'
backend_keycloak_realm: 'PLGrid'

# github repo settings
frontend_repo_version: 'dependabot/npm_and_yarn/mui/lab-5.0.0-alpha.150'
backend_repo_version: '682-better-handling-of-error-messages-on-slurm'
frontend_repo_version: 'master'
backend_repo_version: '710-choose-more-efficient-db-engine'

0 comments on commit b9c6e8b

Please sign in to comment.