Add SKIP_DB_PING to skip database availability test (#2346)

* Add new envvar `SKIP_DB_PING` to instruct the CTFd Docker image to not test if the database server is available

---------

Co-authored-by: Smyler <smyler@hackademint.org>
This commit is contained in:
Kevin Chung
2023-06-28 00:45:57 -04:00
committed by GitHub
parent 1226267faa
commit 79ae94285c

View File

@@ -7,6 +7,7 @@ ACCESS_LOG=${ACCESS_LOG:--}
ERROR_LOG=${ERROR_LOG:--} ERROR_LOG=${ERROR_LOG:--}
WORKER_TEMP_DIR=${WORKER_TEMP_DIR:-/dev/shm} WORKER_TEMP_DIR=${WORKER_TEMP_DIR:-/dev/shm}
SECRET_KEY=${SECRET_KEY:-} SECRET_KEY=${SECRET_KEY:-}
SKIP_DB_PING=${SKIP_DB_PING:-false}
# Check that a .ctfd_secret_key file or SECRET_KEY envvar is set # Check that a .ctfd_secret_key file or SECRET_KEY envvar is set
if [ ! -f .ctfd_secret_key ] && [ -z "$SECRET_KEY" ]; then if [ ! -f .ctfd_secret_key ] && [ -z "$SECRET_KEY" ]; then
@@ -18,8 +19,11 @@ if [ ! -f .ctfd_secret_key ] && [ -z "$SECRET_KEY" ]; then
fi fi
fi fi
# Skip db ping if SKIP_DB_PING is set to a value other than false or empty string
if [[ "$SKIP_DB_PING" == "false" ]]; then
# Ensures that the database is available # Ensures that the database is available
python ping.py python ping.py
fi
# Initialize database # Initialize database
python manage.py db upgrade python manage.py db upgrade