feat(startup): add the DB_WAIT environment var

pull/83/head
xxxxxliil 2021-06-02 16:02:25 +08:00
parent 480775c328
commit 628b5a4fa0
3 changed files with 19 additions and 15 deletions

View File

@ -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 \

View File

@ -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 |

View File

@ -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