From 06f071536906923f7202761530b5a4838c678736 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Mon, 21 Jan 2019 22:40:23 -0500 Subject: [PATCH] Allow custom MySQL ports in docker entrypoint (#848) * Allow DATABASE_URL to contain custom MySQL ports for docker-entrypoint.sh * Drop WORKERS count to 1 to avoid dealing with Flask-SocketIO sticky sessions --- docker-compose.yml | 2 +- docker-entrypoint.sh | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 98db50e..8ed2285 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - UPLOAD_FOLDER=/var/uploads - DATABASE_URL=mysql+pymysql://root:ctfd@db/ctfd - REDIS_URL=redis://cache:6379 - - WORKERS=4 + - WORKERS=1 - LOG_FOLDER=/var/log/CTFd - ACCESS_LOG=- - ERROR_LOG=- diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 51c3bee..eaa885c 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -18,9 +18,11 @@ fi # Check that the database is available if [ -n "$DATABASE_URL" ] then - database=`echo $DATABASE_URL | awk -F[@//] '{print $4}'` - echo "Waiting for $database to be ready" - while ! mysqladmin ping -h $database --silent; do + url=`echo $DATABASE_URL | awk -F[@//] '{print $4}'` + database=`echo $url | awk -F[:] '{print $1}'` + port=`echo $url | awk -F[:] '{print $2}'` + echo "Waiting for $database:$port to be ready" + while ! mysqladmin ping -h "$database" -P "$port" --silent; do # Show some progress echo -n '.'; sleep 1;