26 lines
1.3 KiB
Cheetah
26 lines
1.3 KiB
Cheetah
#!/bin/sh
|
|
|
|
# Keila reads no *_FILE variables: config/runtime.exs takes its configuration straight from the environment. So load the Docker secrets here, before handing over to the release binary.
|
|
#
|
|
# The file name maps directly to the variable name, uppercased:
|
|
# /run/secrets/secret_key_base -> SECRET_KEY_BASE
|
|
# /run/secrets/mailer_smtp_password -> MAILER_SMTP_PASSWORD
|
|
#
|
|
# That means a new compose overlay needs no change here: declare the secret with the lowercased name of the variable it feeds and it is picked up.
|
|
if [ -d /run/secrets ]; then
|
|
for secret_file in /run/secrets/*; do
|
|
[ -f "$secret_file" ] || continue
|
|
var_name=$(basename "$secret_file" | tr '[:lower:]-' '[:upper:]_')
|
|
export "$var_name=$(cat "$secret_file")"
|
|
done
|
|
fi
|
|
|
|
# Keila accepts one connection URL and offers no discrete host/user/password variables (config/runtime.exs calls System.fetch_env!("DB_URL")). A `db_url` secret, if you inserted one for a managed database, was already exported above and wins. Otherwise assemble the URL from the postgres_password secret, so the password never has to sit in the env file.
|
|
if [ -z "${DB_URL}" ] && [ -n "${POSTGRES_HOST}" ]; then
|
|
export DB_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/${POSTGRES_DB}"
|
|
fi
|
|
|
|
echo "....Secrets have been loaded, now run $@...."
|
|
|
|
exec "$@"
|