From 908da629ecb71cdc007735c7bf2195e0bd5a643f Mon Sep 17 00:00:00 2001
From: asuch <asuch@syncad.com>
Date: Tue, 14 Jan 2025 11:23:30 +0100
Subject: [PATCH] Remove postgrest.conf. All postgrest configuration in
 start_postgrest.sh scripts and variables

---
 Dockerfile                          | 1 -
 docker/docker_entrypoint.sh         | 4 ++--
 postgrest.conf                      | 7 -------
 scripts/{ci => }/start_postgrest.sh | 8 ++++++--
 4 files changed, 8 insertions(+), 12 deletions(-)
 delete mode 100644 postgrest.conf
 rename scripts/{ci => }/start_postgrest.sh (79%)

diff --git a/Dockerfile b/Dockerfile
index 285fe18aa..d90267239 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -132,7 +132,6 @@ COPY --from=builder --chown=hivemind:hivemind  /home/hivemind/app/haf/scripts/co
 COPY --from=builder --chown=hivemind:hivemind  /home/hivemind/app/mock_data/block_data /home/hivemind/app/mock_data/block_data
 COPY --from=builder --chown=hivemind:hivemind  /home/hivemind/app/mock_data/vops_data /home/hivemind/app/mock_data/vops_data
 COPY --from=builder --chown=hivemind:hivemind  --exclude=haf/* /home/hivemind/app/reputation_tracker /home/hivemind/app/reputation_tracker
-COPY --from=builder --chown=hivemind:hivemind  /home/hivemind/app/postgrest.conf .
 
 # JSON rpc service
 EXPOSE ${HTTP_PORT}
diff --git a/docker/docker_entrypoint.sh b/docker/docker_entrypoint.sh
index 0824a9b88..77e5d4986 100755
--- a/docker/docker_entrypoint.sh
+++ b/docker/docker_entrypoint.sh
@@ -105,11 +105,11 @@ run_server() {
   if [[ -n "$LOG_PATH" ]]; then
     log "run_hive" "Starting hivemind postgrest server with log $LOG_PATH"
     echo "Running postgrest setup..."
-    exec "$SCRIPT_DIR/app/ci/start_postgrest.sh" "${HIVEMIND_ARGS[@]}" --postgres-url="${POSTGRES_URL}" > >( tee -i "$LOG_PATH" ) 2>&1
+    exec "$SCRIPT_DIR/app/start_postgrest.sh" "${HIVEMIND_ARGS[@]}" --postgres-url="${POSTGRES_URL}" > >( tee -i "$LOG_PATH" ) 2>&1
   else
     log "run_hive" "Starting hivemind postgrest server..."
     echo "Running postgrest setup..."
-    exec "$SCRIPT_DIR/app/ci/start_postgrest.sh" "${HIVEMIND_ARGS[@]}" --postgres-url="${POSTGRES_URL}"
+    exec "$SCRIPT_DIR/app/start_postgrest.sh" "${HIVEMIND_ARGS[@]}" --postgres-url="${POSTGRES_URL}"
   fi
 }
 
diff --git a/postgrest.conf b/postgrest.conf
deleted file mode 100644
index f575399ab..000000000
--- a/postgrest.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-db-uri = "postgres://haf_admin@/haf_block_log"
-db-schema = "hivemind_endpoints"
-db-anon-role = "hivemind"
-db-pool = 20
-db-pool-acquisition-timeout = 10
-server-port = 8080
-admin-server-port = 3001
diff --git a/scripts/ci/start_postgrest.sh b/scripts/start_postgrest.sh
similarity index 79%
rename from scripts/ci/start_postgrest.sh
rename to scripts/start_postgrest.sh
index b55ceaf76..5443b56a1 100755
--- a/scripts/ci/start_postgrest.sh
+++ b/scripts/start_postgrest.sh
@@ -54,9 +54,13 @@ start_webserver() {
     export PGRST_SERVER_PORT=$WEBSERVER_PORT
     export PGRST_ADMIN_SERVER_PORT=$ADMIN_PORT
     export PGRST_LOG_LEVEL=$LOG_LEVEL
-    #export PGRST_DB_ROOT_SPEC="home"
+    export PGRST_DB_SCHEMAS="hivemind_endpoints"
+    export PGRST_DB_ANON_ROLE="hivemind"
+    export PGRST_DB_POOL=20
+    export PGRST_DB_POOL_ACQUISITION_TIMEOUT=10
+    #export PGRST_DB_ROOT_SPEC="home" #this may be need to be uncommented in local environment to let tests work, if empty jsons are 
 
-    postgrest postgrest.conf
+    postgrest
 }
 
 start_webserver
-- 
GitLab