From f886e6ef8963c4abd149796f09711dfd73276abb Mon Sep 17 00:00:00 2001
From: baloola <baloola-mu@hotmail.com>
Date: Wed, 16 Sep 2020 16:28:53 +0200
Subject: [PATCH] export variables into bash.bashrc

---
 core/entrypoint.sh       | 16 +++++++---------
 docker-compose.vhr18.yml |  6 ++++++
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/core/entrypoint.sh b/core/entrypoint.sh
index 86dad559..1b8bb999 100644
--- a/core/entrypoint.sh
+++ b/core/entrypoint.sh
@@ -15,6 +15,7 @@ fi
 # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
 #  "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
 file_env() {
+
 	local var="$1"
 	local fileVar="${var}_FILE"
 	local def="${2:-}"
@@ -27,17 +28,14 @@ file_env() {
 	elif [ "${!fileVar:-}" ]; then
 		val="$(< "${!fileVar}")"
 	fi
-	export "$var"="$val"
-    echo " the ${var} shall be set to ${val}"
+	cat >> /etc/bash.bashrc <<EOF
+export ${var}=${val}
+EOF
+
 	unset "$fileVar"
 }
-# Loads various settings that are used elsewhere in the script
-# This should be called after mysql_check_config, but before any other functions
-docker_setup_env() {
 
-	# Initialize values that might be stored in a file
-	file_env 'OS_PASSWORD'
+file_env "OS_PASSWORD"
+
 
-}
-docker_setup_env "$@"
 eval "/opt/eoxserver/eoxserver-entrypoint.sh $@"
diff --git a/docker-compose.vhr18.yml b/docker-compose.vhr18.yml
index 8b808a9d..243427ea 100644
--- a/docker-compose.vhr18.yml
+++ b/docker-compose.vhr18.yml
@@ -129,6 +129,8 @@ services:
       - env/vhr18_db.env
       - env/vhr18_obs.env
       - env/vhr18_redis.env
+    secrets:
+      - OS_PASSWORD
     environment:
       INSTANCE_ID: "prism-view-server_registrar"
       INSTALL_DIR: "/var/www/pvs/dev/"
@@ -138,6 +140,7 @@ services:
       INIT_SCRIPTS: "/configure.sh /init-db.sh /initialized.sh"
       STARTUP_SCRIPTS: "/wait-initialized.sh"
       WAIT_SERVICES: "redis:6379 database:5432"
+      OS_PASSWORD_FILE: "/run/secrets/OS_PASSWORD"
     configs:
       - source: init-db
         target: /init-db.sh
@@ -169,3 +172,6 @@ volumes:
   instance-data:
 networks:
   intnet:
+secrets:
+  OS_PASSWORD:
+    external: true
-- 
GitLab