Skip to content

Commit

Permalink
Merge pull request #309 from DennisGaida/patch-1
Browse files Browse the repository at this point in the history
Support docker secrets for username and password
  • Loading branch information
bropat authored Mar 7, 2024
2 parents f56e3c7 + e3f5538 commit 01659db
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#!/bin/bash

# allow setting specific environment variables with docker secrets
# the format is <variable-name>_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
Expand Down

0 comments on commit 01659db

Please sign in to comment.