From e04ff6f8d180ddb72d621432d3da409100649698 Mon Sep 17 00:00:00 2001 From: Philip Ebels Date: Tue, 4 Sep 2018 17:35:41 +0200 Subject: [PATCH] Wait for mysql to be up before executing --- docker-entrypoint.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7c00d206d7..5b5d01825e 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,3 +1,15 @@ #!/bin/sh + +set -e + +until nc -z -v -w30 $DATABASE_HOST 3306 +do + echo "Waiting for database connection..." + # wait for 5 seconds before check again + sleep 5 +done + +echo "Mysql is up - executing command" + cd /usr/src/app/ node index.js -h $DATABASE_HOST -p $DATABASE_PASSWORD -d $DATABASE_NAME -u $DATABASE_USER -n 80 -r 0.0.0.0