diff --git a/Dockerfile b/Dockerfile index c50eb99..9bdeceb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ ENV GID=991 \ DB_USER=flarum \ DB_NAME=flarum \ DB_PORT=3306 \ + DB_WAIT=false \ FLARUM_TITLE=Docker-Flarum \ DEBUG=false \ LOG_TO_STDOUT=false \ diff --git a/README.md b/README.md index bebd284..9553810 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ | **DB_PASS** | MariaDB database password | **required** | none | **DB_PREF** | Flarum tables prefix | *optional* | none | **DB_PORT** | MariaDB database port | *optional* | 3306 +| **DB_WAIT** | Wait database live | *optional* | false | **FLARUM_PORT** | Port to run Flarum on inside the container | *optional* | 8888 | **UPLOAD_MAX_SIZE** | The maximum size of an uploaded file | *optional* | 50M | **PHP_MEMORY_LIMIT** | PHP memory limit | *optional* | 128M | diff --git a/rootfs/usr/local/bin/startup b/rootfs/usr/local/bin/startup index f087a6f..f12fad7 100644 --- a/rootfs/usr/local/bin/startup +++ b/rootfs/usr/local/bin/startup @@ -66,21 +66,23 @@ if [ -f '/flarum/app/extensions/composer.repositories.txt' ]; then fi # Wait database live -test_count=0 -test_db(){ - db-live-test --dsn "mysql:host=${DB_HOST};port=${DB_PORT};database=${DB_NAME}" \ - --user ${DB_USER} \ - --password ${DB_PASS} -} -echo "[INFO] Waiting for the database live..." -until test_db; do - if [ "${test_count}" = 40 ]; then - echo "[ERROR] The database not live!" >&2 - exit 75 - fi - test_count=$(($test_count + 1)) - sleep 1 -done +if [ "${DB_WAIT}" = 'true' ]; then + test_count=0 + test_db(){ + db-live-test --dsn "mysql:host=${DB_HOST};port=${DB_PORT};database=${DB_NAME}" \ + --user ${DB_USER} \ + --password ${DB_PASS} + } + echo "[INFO] Waiting for the database live..." + until test_db; do + if [ "${test_count}" = 40 ]; then + echo "[ERROR] The database not live!" >&2 + exit 75 + fi + test_count=$(($test_count + 1)) + sleep 1 + done +fi # if installation was performed before if [ -e '/flarum/app/public/assets/rev-manifest.json' ] || [ -e '/flarum/app/public/assets/._flarum-installed.lock' ] ; then