Add docker-entrypoint.sh
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
tobias 2024-06-05 22:29:51 +02:00
parent 3aa8aa144c
commit ccb71a276b

32
docker-entrypoint.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
set -eu
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
file_env "TOKEN"
file_env "MONGODB_PASSWORD"
file_env "PAYLOAD_SECRET"
export MONGODB_URI="mongodb://$MONGODB_USER:$MONGODB_PASSWORD@$MONGODB_HOST:$MONGODB_PORT"
"$@"