Skip to content

Docker Deployment, RTX KG2

Amy Glen edited this page Aug 19, 2022 · 1 revision

Name and Description

RTX-KG2 API

The RTX-KG2 API is a means of accessing the RTX-KG2 knowledge graph. RTX-KG2 is the second-generation knowledge graph for the ARAX biomedical reasoning system. This Github repository contains all of the code for building KG2 as well as all of the documentation about how to build, host, access, and use KG2.

GitHub path

Docker file is located at at RTX/DockerBuild/KG2-Dockerfile

Configuration File

The configuration file must be placed within the container at the following path:

/mnt/data/orangeboard/kg2/RTX/code/config_secrets.json

Database files

Database files including their parent directory should be placed inside the container at the following path:

/mnt/data/orangeboard/databases/

I.E. if a database file database.sqlite is stored in the KG2.5.2 directory it should be placed inside the container as:

/mnt/data/orangeboard/databases/KG2.5.2/database.sqlite

Build and Configuration

Ensure that the host machine has a minimum of 64 GB of RAM and 600GB of available disk space. We currently use a m5a.4xlarge AWS EC2 instance.

To configure the host machine do the following:

  1. Ensure that docker and git are installed
  2. Ensure that SSL certifications set up on the host machine and that a port is open to be bound to port 80 inside the container. (for the purposes of this documentation we will use port 8080)
  3. ensure nginx is installed and configured with a similar configuration file (paths, server names, ect changed to match host machine configuration) Or setup something similar using a different software/service:
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 80;
    server_name <newserver>;
    return 302 https://$host$request_uri;
}

server {
    listen 443 ssl;
    ssl on;

    server_name <newserver>;
    root /etc/nginx/www;

    ssl_certificate             /etc/letsencrypt/live/<newserver>/fullchain.pem;
    ssl_certificate_key         /etc/letsencrypt/live/<newserver>/privkey.pem;
    ssl_protocols               TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers   on;
    ssl_ciphers                 "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_ecdh_curve              secp384r1;
    ssl_session_timeout         1d;
    ssl_session_cache           shared:SSL:50m;
    ssl_dhparam                 /etc/nginx/dhparam.pem;
    ssl_stapling                on;
    ssl_stapling_verify         on;

    add_header    Strict-Transport-Security   max-age=15768000;

    server_tokens         off;

    location /.well-known {
    	try_files $uri $uri/ =404;
        add_header 'Access-Control-Allow-Origin' '*';
    }
    
    location / {
	proxy_read_timeout 3000s;
        add_header 'X-Frame-Options' 'SAMEORIGIN';
	proxy_buffering off;

	include proxy_params;
	proxy_pass http://localhost:8080;
	proxy_set_header  X-Forwarded-Proto $scheme;
	proxy_set_header  X-Real-IP         $remote_addr;
	proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
	proxy_set_header  X-Real-IP-AWS	    $remote_addr;
    }
}

To build a new docker image:

  1. clone the RTX repo git clone https://github.com/RTXteam/RTX.git
  2. Build the docker image docker build --no-cache=true --rm -t arax:kg2 ./RTX/DockerBuild/ -f ./RTX/DockerBuild/KG2-Dockerfile
  3. Run the container docker run -d -it --name kg2 -p 8080:80 arax:kg2
  4. Ensure that both the configuration file and database files are placed in the correct locations inside the container as detailed above.
  5. From inside the container run the following to create the correct symlinks to the database files:
su rt && cd /mnt/data/orangeboard/kg2/RTX && python3 code/ARAX/ARAXQuery/ARAX_database_manager.py
  1. Run the following from inside the container as root to start the service:
service apache2 start
service RTX_OpenAPI_kg2 start

Testing

To test that the system is working correctly run the following inside the container:

su rt && cd /mnt/data/orangeboard/kg2/RTX/code/ARAX/test && pytest -v