From 4794c59f59fda38b0be395792dc3b9216e35e53a Mon Sep 17 00:00:00 2001 From: thopic Date: Sun, 23 May 2021 17:26:01 +0200 Subject: [PATCH] Improve the way app waits for db to be ready credits : https://gitlab.utc.fr/picasoft/projets/dockerfiles/-/merge_requests/64 --- app/Dockerfile | 1 + app/entrypoint.sh | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Dockerfile b/app/Dockerfile index 78190c4..3a757b9 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -25,6 +25,7 @@ RUN apk add --no-cache \ netcat-openbsd \ xmlsec-dev \ tzdata \ + postgresql-client \ && rm -rf /tmp/* # Get Mattermost diff --git a/app/entrypoint.sh b/app/entrypoint.sh index 40808da..7e57e8e 100755 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -74,7 +74,11 @@ if [ "$1" = 'mattermost' ]; then # Wait another second for the database to be properly started. # Necessary to avoid "panic: Failed to open sql connection pq: the database system is starting up" - sleep 1 + until pg_isready -h $DB_HOST -p $DB_PORT_NUMBER + do + echo "Database is not ready yet. Waiting 5 seconds." + sleep 5 + done echo "Starting mattermost" fi