From c8ec88219015d30c1eee9255baf629d94bef2880 Mon Sep 17 00:00:00 2001
From: Dominik George <dominik.george@teckids.org>
Date: Thu, 14 Nov 2019 12:32:10 +0100
Subject: [PATCH] Use empty postgresql password by default, but pass in
 everywhere if defined.

---
 docker-compose.yaml  | 2 --
 docker/entrypoint.sh | 6 +++++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/docker-compose.yaml b/docker-compose.yaml
index f047e1d7f..337818ab8 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -7,7 +7,6 @@ services:
       - postgres_data:/var/lib/postgresql/data/
     environment:
       - POSTGRES_USER=biscuit
-      - POSTGRES_PASSWORD=biscuit
       - POSTGRES_DB=biscuit
   memcached:
     image: memcached:latest
@@ -21,7 +20,6 @@ services:
       - BISCUIT_secret_key=DoNotUseInProduction
       - BISCUIT_http__allowed_hosts="['*']"
       - BISCUIT_database__host=db
-      - BISCUIT_database__password=biscuit
       - BISCUIT_caching__memcached__address=memcached:11211
     depends_on:
       - db
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
index 0d80fd6f0..a5039fdcd 100755
--- a/docker/entrypoint.sh
+++ b/docker/entrypoint.sh
@@ -1,8 +1,12 @@
 #!/bin/bash
 
 GUNICORN_BIND=${GUNICORN_BIND:-0.0.0.0:8000}
+POSTGRES_HOST=${BISCUIT_database__host:-127.0.0.1}
+POSTGRES_PORT=${BISCUIT_database__port:-5432}
 
-while ! nc -z ${BISCUIT_database__host} 5432; do
+[[ -n $POSTGRES_PASSWORD ]] && BISCUIT_database__password=$POSTGRES_PASSWORD
+
+while ! nc -z $POSTGRES_HOST $POSTGRES_PORT; do
     sleep 0.1
 done
 
-- 
GitLab