From fe3cb76a190ad87f3d55233a44eaae46b3f8fe05 Mon Sep 17 00:00:00 2001 From: quacktacular Date: Fri, 11 Sep 2020 02:02:24 -0700 Subject: [PATCH] chore: allow DATABASE_URL env to take presedence over individual connection params. (#1147) fixes: #1147 Co-authored-by: Pranav Raj S --- docker/entrypoints/rails.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docker/entrypoints/rails.sh b/docker/entrypoints/rails.sh index 3774a8b63..80dee70ba 100755 --- a/docker/entrypoints/rails.sh +++ b/docker/entrypoints/rails.sh @@ -8,8 +8,14 @@ rm -rf /app/tmp/cache/* echo "Waiting for postgres to become ready...." -PGPASSWORD=$POSTGRES_PASSWORD -PSQL="pg_isready -h $POSTGRES_HOST -p 5432 -U $POSTGRES_USERNAME" +# Let DATABASE_URL env take presedence over individual connection params. +if [ -z "$DATABASE_URL" ]; then + PGPASSWORD=$POSTGRES_PASSWORD + PSQL="pg_isready -h $POSTGRES_HOST -p 5432 -U $POSTGRES_USERNAME" +else + PSQL="pg_isready -d $DATABASE_URL" +fi + until $PSQL do sleep 2;