feat(startup): add wait db live
parent
a47a8ab49e
commit
480775c328
|
@ -54,6 +54,7 @@ RUN apk add --no-progress --no-cache \
|
||||||
&& cd /tmp \
|
&& cd /tmp \
|
||||||
&& ln -s /usr/bin/php8 /usr/bin/php \
|
&& ln -s /usr/bin/php8 /usr/bin/php \
|
||||||
&& curl -s http://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
&& 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 \
|
&& sed -i 's/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/' /etc/php8/php.ini \
|
||||||
&& chmod +x /usr/local/bin/composer \
|
&& chmod +x /usr/local/bin/composer \
|
||||||
&& mkdir -p /run/php /flarum/app \
|
&& mkdir -p /run/php /flarum/app \
|
||||||
|
|
|
@ -65,6 +65,23 @@ if [ -f '/flarum/app/extensions/composer.repositories.txt' ]; then
|
||||||
done < /flarum/app/extensions/composer.repositories.txt
|
done < /flarum/app/extensions/composer.repositories.txt
|
||||||
fi
|
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 installation was performed before
|
||||||
if [ -e '/flarum/app/public/assets/rev-manifest.json' ] || [ -e '/flarum/app/public/assets/._flarum-installed.lock' ] ; then
|
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..."
|
echo "[INFO] Flarum already installed, init app..."
|
||||||
|
|
Loading…
Reference in New Issue