From 82e5ed3e6ba4ff2c5cc0e9cd94a307bd6e0fd444 Mon Sep 17 00:00:00 2001
From: Konrad Botor <kbotor@syncad.com>
Date: Mon, 10 Feb 2025 14:33:12 +0100
Subject: [PATCH] Fix for minimal image build from submodule

---
 Dockerfile                  | 2 ++
 docker/docker_entrypoint.sh | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 05a4adf42..c600e5e5a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -277,6 +277,8 @@ COPY --from=build --chown=postgres:postgres "${HAF_SOURCE_DIR}/docker/pg_hba.con
 
 COPY --from=build --chown=haf_admin:users "${HAF_SOURCE_DIR}/docker/cron_jobs.sql" .
 
+# Reset HIVE_SUBDIR after copying files from build stage
+ENV HIVE_SUBDIR=.
 ENV DATADIR=/home/hived/datadir
 # Use default location (inside datadir) of shm file. If SHM should be placed on some different device, then set it to mapped volume `/home/hived/shm_dir` and map it in docker run
 ENV SHM_DIR=${DATADIR}/blockchain
diff --git a/docker/docker_entrypoint.sh b/docker/docker_entrypoint.sh
index 0429cc67b..d390d744b 100755
--- a/docker/docker_entrypoint.sh
+++ b/docker/docker_entrypoint.sh
@@ -254,7 +254,7 @@ if sudo --user=postgres -n [ ! -d "$PGDATA" -o ! -f "$PGDATA/PG_VERSION" ]; then
 
   echo "Attempting to setup postgres instance: running setup_postgres.sh..."
 
-  sudo -n "/home/haf_admin/source/${HIVE_SUBDIR}/scripts/setup_postgres.sh" --haf-admin-account=haf_admin --haf-binaries-dir="/home/haf_admin/build" --haf-database-store="/home/hived/datadir/haf_db_store/tablespace" --install-extension=${HAF_INSTALL_EXTENSION:-yes}
+  sudo -n "/home/haf_admin/source/${HIVE_SUBDIR}/scripts/setup_postgres.sh" --haf-admin-account=haf_admin --haf-binaries-dir="/home/haf_admin/build" --haf-database-store="/home/hived/datadir/haf_db_store/tablespace" --install-extension="${HAF_INSTALL_EXTENSION:-"yes"}"
 
   echo "Postgres instance setup completed."
 
@@ -265,7 +265,7 @@ else
   echo "Attempting to setup postgres instance already containing HAF database..."
 
   # in case when container is restarted over already existing (and potentially filled) data directory, we need to be sure that docker-internal postgres has deployed HFM extension
-  sudo -n "/home/haf_admin/source/${HIVE_SUBDIR}/scripts/setup_postgres.sh" --haf-admin-account=haf_admin --haf-binaries-dir="/home/haf_admin/build" --haf-database-store="/home/hived/datadir/haf_db_store/tablespace" --install-extension=${HAF_INSTALL_EXTENSION:-yes}
+  sudo -n "/home/haf_admin/source/${HIVE_SUBDIR}/scripts/setup_postgres.sh" --haf-admin-account=haf_admin --haf-binaries-dir="/home/haf_admin/build" --haf-database-store="/home/hived/datadir/haf_db_store/tablespace" --install-extension="${HAF_INSTALL_EXTENSION:-"yes"}"
   sudo -n "/usr/share/postgresql/${POSTGRES_VERSION}/extension/hive_fork_manager_update_script_generator.sh" --haf-admin-account=haf_admin --haf-db-name=haf_block_log
 
   echo "Postgres instance setup completed."
-- 
GitLab