Fix docker-entrypoint broke for Other name than "postgres"

This commit is contained in:
Valentin Ouvrard
2018-03-08 10:04:29 +11:00
parent 88deb5fc47
commit 452904398f

View File

@@ -23,7 +23,16 @@ server() {
}
create_db() {
while ! bash -c "echo > /dev/tcp/postgres/5432" &> /dev/null ; do
DATABASE_FULLURL=$(echo $REDASH_DATABASE_URL |cut -d '@' -f2 |sed 's,/.*,,g')
if [[ $DATABASE_FULLURL = *":"* ]]; then
DATABASE_URL=$(echo $DATABASE_FULLURL |cut -d ':' -f1)
DATABASE_PORT=$(echo $DATABASE_FULLURL |cut -d ':' -f2)
else
DATABASE_URL=$(echo $DATABASE_FULLURL)
DATABASE_PORT="5432"
fi
while ! bash -c "echo > /dev/tcp/$DATABASE_URL/$DATABASE_PORT" &> /dev/null ; do
echo "Waiting for PostgreSQL container to become available."
sleep 5
done
@@ -97,3 +106,4 @@ case "$1" in
exec "$@"
;;
esac