From e3f5538d2237c47181cb9a0b99553c05e0cd7f8b Mon Sep 17 00:00:00 2001 From: Dennis Gaida <2392217+DennisGaida@users.noreply.github.com> Date: Mon, 4 Mar 2024 09:39:33 +0100 Subject: [PATCH] Support docker secrets for username and password I don't like confidential data just hanging around in environment variables, especially for security related products. --- docker/run.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docker/run.sh b/docker/run.sh index 93867e6..e99ed31 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,5 +1,20 @@ #!/bin/bash +# allow setting specific environment variables with docker secrets +# the format is _FILE +supportedSecrets=( "USERNAME" + "PASSWORD" + ) +for secret in ${supportedSecrets[@]}; do + envFile="${secret}_FILE" + if [ $(printenv ${envFile}) ]; then envFileName=`printenv ${envFile}`; fi + if [[ ${!envFile} && -f "$envFileName" ]]; then + val=`cat $envFileName` + export "${secret}"="$val" + echo "${secret} environment variable was set by secret ${envFile}" + fi +done + if [ -z "${USERNAME}" ] || [ -z "${PASSWORD}" ]; then echo "Missing one of USERNAME or PASSWORD" exit 1