From 7359a6ba56d8baa04c4b4f5d2691ecf6e50b05d0 Mon Sep 17 00:00:00 2001 From: Alyssa Dai Date: Tue, 16 Apr 2024 16:58:09 -0400 Subject: [PATCH 1/4] use internal port in graph container for GraphDB operations --- dev/graphdb_setup.sh | 16 ++++++++-------- dev/setup.sh | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dev/graphdb_setup.sh b/dev/graphdb_setup.sh index 62a16f5..676d18f 100755 --- a/dev/graphdb_setup.sh +++ b/dev/graphdb_setup.sh @@ -128,12 +128,12 @@ echo "Environment variables have been set from ${ENV_FILE_PATH}." # Extract just the database name DB_NAME="${NB_GRAPH_DB#repositories/}" -NB_GRAPH_PORT_HOST=${NB_GRAPH_PORT_HOST:-7200} +NB_GRAPH_PORT=${NB_GRAPH_PORT:-7200} # Get the directory of this script to be able to find the data-config_template.ttl file SCRIPT_DIR=$(dirname "$0") -echo "The GraphDB server is being accessed at http://localhost:${NB_GRAPH_PORT_HOST}." +echo "The GraphDB server is being accessed at http://localhost:${NB_GRAPH_PORT}." ##### First time GraphDB setup ##### @@ -143,14 +143,14 @@ if [ "${RUN_USER_SETUP}" = "on" ]; then # 1. Change database admin password echo "Changing the admin password (note: if you have previously set the admin password, this has no effect)..." # TODO: To change a *previously set* admin password, we need to also provide the current password via -u - curl -X PATCH --header 'Content-Type: application/json' http://localhost:${NB_GRAPH_PORT_HOST}/rest/security/users/admin -d "{\"password\": \""${ADMIN_PASS}"\"}" + curl -X PATCH --header 'Content-Type: application/json' http://localhost:${NB_GRAPH_PORT}/rest/security/users/admin -d "{\"password\": \""${ADMIN_PASS}"\"}" # 2. If security is not enabled, enable it (i.e. allow only authenticated users access) - is_security_enabled=$(curl -s -X GET http://localhost:${NB_GRAPH_PORT_HOST}/rest/security) + is_security_enabled=$(curl -s -X GET http://localhost:${NB_GRAPH_PORT}/rest/security) if [ "${is_security_enabled}" = "false" ]; then echo "Enabling password-based access control to all databases ..." # NOTE: This command fails without credentials once security is enabled - curl -X POST --header 'Content-Type: application/json' -d true http://localhost:${NB_GRAPH_PORT_HOST}/rest/security + curl -X POST --header 'Content-Type: application/json' -d true http://localhost:${NB_GRAPH_PORT}/rest/security else echo "Password-based access control has already been enabled." fi @@ -159,7 +159,7 @@ if [ "${RUN_USER_SETUP}" = "on" ]; then # TODO: Separate this out from the first-time setup? As this can technically be run at any time to create additional users. # NOTE: If user already exists, response will be "An account with the given username already exists." OK for script. echo "Creating a new database user ${NB_GRAPH_USERNAME}..." - curl -X POST --header 'Content-Type: application/json' -u "admin:${ADMIN_PASS}" -d @- http://localhost:${NB_GRAPH_PORT_HOST}/rest/security/users/${NB_GRAPH_USERNAME} < Date: Tue, 16 Apr 2024 17:13:54 -0400 Subject: [PATCH 2/4] replace usable default for NB_API_QUERY_URL with placeholder --- dev/docker-compose.yml | 2 +- dev/template.env | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index 394e282..a5a7e51 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -58,4 +58,4 @@ services: ports: - "${NB_QUERY_PORT_HOST:-3000}:5173" environment: - NB_API_QUERY_URL: ${NB_API_QUERY_URL:-http://localhost:8000/} \ No newline at end of file + NB_API_QUERY_URL: ${NB_API_QUERY_URL} \ No newline at end of file diff --git a/dev/template.env b/dev/template.env index 47070ad..daa746c 100644 --- a/dev/template.env +++ b/dev/template.env @@ -37,8 +37,8 @@ NB_FAPI_PORT_HOST=8080 NB_FAPI_TAG=latest # ---- CONFIGURATION FOR QUERY TOOL ---- -# URL of the f-API as it will appear to a user -NB_API_QUERY_URL=http://localhost:8080 +# URL of the n-API/f-API the query to will talk to, as it appears to a user +NB_API_QUERY_URL=http://XX.XX.XX.XX # REPLACE WITH YOUR API URL (AND PORT, IF APPLICABLE) AS IT APPEARS ON A USER'S MACHINE, OR localhost: IF QUERY TOOL WILL ONLY BE ACCESSED FROM ITS HOST MACHINE # Docker image tag of the query tool (default latest) NB_QUERY_TAG=latest # Port that the query tool will be exposed on the host and likely the network (default 3000) From 727bb7bdb9abe1c47e9a5af28bcd3f212db3cd32 Mon Sep 17 00:00:00 2001 From: Alyssa Dai Date: Wed, 17 Apr 2024 22:54:57 -0400 Subject: [PATCH 3/4] echo port used inside graph container --- dev/setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/setup.sh b/dev/setup.sh index fded85e..71d0a5f 100755 --- a/dev/setup.sh +++ b/dev/setup.sh @@ -13,7 +13,8 @@ SCRIPT_DIR=$(dirname "$0") # Logic for main setup main() { - echo -e "Setting up a Neurobagel graph backend...\n" + echo "Setting up a Neurobagel graph backend..." + echo -e "(The GraphDB server is being accessed inside the GraphDB container at http://localhost:${NB_GRAPH_PORT}.)\n" echo "Setting up GraphDB server..." ./graphdb_setup.sh "${NB_GRAPH_ADMIN_PASSWORD}" From e0eab92d42f04989eb06e8bf8062a6c9d126c93b Mon Sep 17 00:00:00 2001 From: Alyssa Dai Date: Wed, 17 Apr 2024 22:55:57 -0400 Subject: [PATCH 4/4] switch to above-line comments only --- dev/template.env | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dev/template.env b/dev/template.env index daa746c..a9cd4cf 100644 --- a/dev/template.env +++ b/dev/template.env @@ -7,8 +7,13 @@ COMPOSE_PROFILES=local_node # ---- CONFIGURATION FOR graph ---- NB_GRAPH_ADMIN_PASSWORD=ADMINPASSWORD -NB_GRAPH_USERNAME=DBUSER # REPLACE DBUSER WITH YOUR GRAPH DATABASE USERNAME -NB_GRAPH_PASSWORD=DBPASSWORD # REPLACE DBPASSWORD WITH YOUR GRAPH DATABASE PASSWORD + +# **REPLACE DBUSER** with your graph database username +NB_GRAPH_USERNAME=DBUSER + +# **REPLACE DBPASSWORD** with your graph database password +NB_GRAPH_PASSWORD=DBPASSWORD + NB_GRAPH_DB=repositories/my_db NB_RETURN_AGG=true NB_NAPI_TAG=latest @@ -17,7 +22,9 @@ LOCAL_GRAPH_DATA=./data # REPLACE WITH PATH TO YOUR JSONLD FILES # ---- CONFIGURATION FOR n-API ---- ## ADDITIONAL CONFIGURABLE PARAMETERS: Uncomment and modify values of the below variables as needed to use non-default values. -NB_NAPI_ALLOWED_ORIGINS="*" # Allow multiple origins of requests. e.g. For a query tool deployed locally using default ports, use: NB_API_ALLOWED_ORIGINS="http://localhost:3000 http://127.0.0.1:3000" +# Allow multiple origins of requests. e.g. For a query tool deployed locally using default ports, use: NB_API_ALLOWED_ORIGINS="http://localhost:3000 http://127.0.0.1:3000" +NB_NAPI_ALLOWED_ORIGINS="*" + NB_NAPI_PORT_HOST=8000 NB_NAPI_PORT=8000 NB_GRAPH_ROOT_HOST=~/graphdb-home @@ -38,8 +45,12 @@ NB_FAPI_TAG=latest # ---- CONFIGURATION FOR QUERY TOOL ---- # URL of the n-API/f-API the query to will talk to, as it appears to a user -NB_API_QUERY_URL=http://XX.XX.XX.XX # REPLACE WITH YOUR API URL (AND PORT, IF APPLICABLE) AS IT APPEARS ON A USER'S MACHINE, OR localhost: IF QUERY TOOL WILL ONLY BE ACCESSED FROM ITS HOST MACHINE +# **REPLACE http://XX.XX.XX.XX** with your API URL (and port, if applicable) as it appears on a user's machine, +# or localhost: if query tool will only be accessed from its host machine +NB_API_QUERY_URL=http://XX.XX.XX.XX + # Docker image tag of the query tool (default latest) NB_QUERY_TAG=latest + # Port that the query tool will be exposed on the host and likely the network (default 3000) NB_QUERY_PORT_HOST=3000 \ No newline at end of file