Files
taiga/entrypoint.sh.tmpl

49 lines
923 B
Bash

#!/bin/bash
set -e
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 "POSTGRES_PASSWORD"
file_env "RABBITMQ_PASS"
# these two should be the same.. for some reason
# the naming is different in the services
file_env "TAIGA_SECRET_KEY"
file_env "SECRET_KEY"
echo "Waiting for Postgres..."
TIMEOUT=30
i=0
until (echo > /dev/tcp/$POSTGRES_HOST/5432) 2>/dev/null; do
i=$((i+1))
if [ $i -ge $TIMEOUT ]; then
echo "Postgres did not start within $TIMEOUT seconds."
exit 1
fi
sleep 1
done
echo "Postgres is ready!"
"$ENTRYPOINT" "$@"