Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update readme #174

Merged
merged 8 commits into from
Nov 8, 2023
Merged
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
78 changes: 3 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,7 @@ To authenticate as admin to Keycloak the predefined user is: admin and password:
To use a different DNS hostname replace localhost with it in .env and src/config.toml \
This configuration is intended for development, DO NOT use it in production.

Use the following instructions if you prefer to use Docker instead of Docker Compose.

### Starting a MySQL Server

We use the default [MySQL Docker image](https://hub.docker.com/_/mysql).
By default, the database is stored within the docker container and will thus be deleted when the container is removed.
Instructions on using a persistent storage can be found at the end of this section.

First, we define a docker network to allow our server to be reachable from other docker containers:

```bash
docker network create sql-network
```

Then, start the MySQL Server:

```bash
docker run -e MYSQL_ROOT_PASSWORD=ok --name sqlserver --network sql-network -d mysql
```

That's all! You should be able to connect to the server now, though no database is present yet:

```bash
docker run -it --network sql-network --rm mysql mysql -hsqlserver -uroot -pok
```
Taniya-Das marked this conversation as resolved.
Show resolved Hide resolved
To connect to the database use `./scripts/database-connect.sql`.

```bash
mysql> SHOW DATABASES;
Expand All @@ -115,48 +91,8 @@ mysql> SHOW DATABASES;
4 rows in set (0.03 sec)
```

For ease of use, you can also make use of the script in `scripts/run_mysql_server.sh`.

#### Persistent Storage
Now, you can visit the server from your browser at `localhost:8000/docs`.

The data is persistent when simply stopping and restarting the server:

```bash
docker stop sqlserver
docker start sqlserver
```

However, all data is lost when the container is deleted.
To ensure data can persist even if the container is deleted, allow the Docker container to write to a directory on the
host machine.
To do that, mount a volume by adding `-v /ABSOLUTE/PATH/TO/HOST/DIR:/var/lib/mysql` to the docker command that starts
the server
(it's also possible to create a docker
volume ([docs](https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only))).
If you want to use a path within this repository directory, we recommend naming the directory `data` since then it will
automatically be ignored by git.
For more information, see "Where to Store Data" in the linked documentation.

### Starting the REST API

The repository provides a Dockerfile to run the REST API in a containerized environment.

#### Using the Docker container

First, build the docker image from the dockerfile:

```bash
docker build --tag ai4eu_server_demo:latest -f Dockerfile .
```

then create a container from that image, remember to forward the port and connect to the right
docker network (alternatively you can use the script at `scripts/run_apiserver.sh`)

```bash
docker run --network sql-network -it --rm -p 8000:8000 --name apiserver ai4eu_server_demo
```

At this point you should be able to visit the server from your browser at `localhost:8000/docs`.

#### Local Installation

Expand Down Expand Up @@ -199,7 +135,7 @@ The `--reload` argument will automatically restart the app if changes are made t
3. Run using DevContainer (see next subsection)

### Authentication
Currently, the code is on default coupled with a keycloak running on test.openml.org. To make
Currently, the code is by default running using the local Keycloak. To make
this work, you need to set an environment variable. You can do this by setting the
`KEYCLOAK_CLIENT_SECRET` in `src/.env`.

Expand All @@ -208,9 +144,6 @@ this work, you need to set an environment variable. You can do this by setting t
KEYCLOAK_CLIENT_SECRET=[SECRET]
```

Please ask Jos van der Velde ([email protected]) for the keycloak secret, and to give your
user the correct roles.

Alternatively, you can connect to a different keycloak instance by modifying `src/.env`. EGI
Checkin can for instance be used on a deployed instance - not on local host. Marco Rorro is the
go-to person to request the usage of the EGI Checkin.
Expand Down Expand Up @@ -255,11 +188,6 @@ You can change this behavior through parameters of the script:
Following the installation instructions above, the server may be reached at `127.0.0.1:8000`.
REST API documentation is automatically built and can be viewed at `127.0.0.1:8000/docs`.

#### Editing Files Locally

While developing the server it is often convenient to edit the files on the host machine.
To avoid rebuilding the docker container each time you edit the files, you can mount the host files into the container.
Mount your repository's `src` directory into the container's `/app` directory by adding `-v $(pwd)/src:/app`.

#### Automatically Restart on Change

Expand Down