diff --git a/Dockerfile b/Dockerfile index f150d47..c50eb99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,6 +54,7 @@ RUN apk add --no-progress --no-cache \ && cd /tmp \ && ln -s /usr/bin/php8 /usr/bin/php \ && curl -s http://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ + && curl -L --progress-bar https://github.com/xxxxxliil/db-live-test/releases/download/0.0.1/db-live-test.php -o /usr/local/bin/db-live-test \ && sed -i 's/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/' /etc/php8/php.ini \ && chmod +x /usr/local/bin/composer \ && mkdir -p /run/php /flarum/app \ diff --git a/rootfs/usr/local/bin/startup b/rootfs/usr/local/bin/startup index 7cffaab..f087a6f 100644 --- a/rootfs/usr/local/bin/startup +++ b/rootfs/usr/local/bin/startup @@ -65,6 +65,23 @@ if [ -f '/flarum/app/extensions/composer.repositories.txt' ]; then done < /flarum/app/extensions/composer.repositories.txt 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 installation was performed before if [ -e '/flarum/app/public/assets/rev-manifest.json' ] || [ -e '/flarum/app/public/assets/._flarum-installed.lock' ] ; then echo "[INFO] Flarum already installed, init app..."