summaryrefslogtreecommitdiff
path: root/.docker/app/updater.sh
diff options
context:
space:
mode:
Diffstat (limited to '.docker/app/updater.sh')
-rw-r--r--.docker/app/updater.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/.docker/app/updater.sh b/.docker/app/updater.sh
index c34cf5225..c38ddd20d 100644
--- a/.docker/app/updater.sh
+++ b/.docker/app/updater.sh
@@ -10,6 +10,30 @@ unset HTTP_HOST
unset ADMIN_USER_PASS
unset AUTO_CREATE_USER_PASS
+# allow setting environment variables with docker secrets
+# the format is <variable-name>__FILE
+SUFFIX="__FILE"
+
+# loop through all environment variables
+for VAR in $(printenv | awk -F= '{print $1}'); do
+ if [[ $VAR == *"$SUFFIX" ]]; then
+ ENV_FILE_NAME="$(printenv "${VAR}")"
+ ENV_VAR="${VAR%$SUFFIX}"
+
+ if printenv "$ENV_VAR" &>/dev/null; then
+ echo "warning: Both $ENV_VAR and $VAR are set. $VAR will override $ENV_VAR."
+ fi
+
+ if [[ -r "$ENV_FILE_NAME" ]]; then
+ VALUE="$(cat "$ENV_FILE_NAME")"
+ export "$ENV_VAR"="$VALUE"
+ echo "$ENV_VAR environment variable was set by secret file $ENV_FILE_NAME"
+ else
+ echo "warning: Secret file $ENV_FILE_NAME for $VAR is not readable or does not exist."
+ fi
+ fi
+done
+
# wait for the app container to delete .app_is_ready and perform rsync, etc.
sleep 30