diff --git a/.docker-config/php/run_queue.sh b/.docker-config/php/run_queue.sh index 06cb5af..e4dc385 100755 --- a/.docker-config/php/run_queue.sh +++ b/.docker-config/php/run_queue.sh @@ -13,17 +13,25 @@ # @license MIT cd /var/www/project +# Wait until the `composer install` is done by looking for the `vendor/autoload.php` file +echo "### Waiting for vendor/autoload.php" +while [ ! -f "composer.lock" ] || [ ! -d "vendor" ] || [ ! -f "vendor/autoload.php" ] +do + sleep 5 +done # Wait until the MySQL db container responds -echo "### Waiting for MySQL database" -until eval "mysql -h mysql -u $CRAFT_DB_USER -p$CRAFT_DB_PASSWORD $CRAFT_DB_DATABASE -e 'select 1' > /dev/null 2>&1" +COMMAND="mysql -h mysql -u $CRAFT_DB_USER -p$CRAFT_DB_PASSWORD $CRAFT_DB_DATABASE -se 'SELECT EXISTS(SELECT * FROM info)'" +# First wait until the command runs without error +until eval "$COMMAND > /dev/null 2>&1" do - sleep 1 + echo "### Waiting for MySQL database" + sleep 5 done -# Wait until the `composer install` is done by looking for the `vendor/autoload.php` file -echo "### Waiting for vendor/autoload.php" -while [ ! -f vendor/autoload.php ] +# Second wait until content in the `info` table exists +until [ $(eval "$COMMAND") != "0" ] do - sleep 1 + echo "### Waiting for database 'info' table" + sleep 5 done # Ensure permissions on directories Craft needs to write to chown -R www-data:www-data /var/www/project/storage diff --git a/CHANGELOG.md b/CHANGELOG.md index db10986..9d4b9b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # nystudio107/spin-up-craft Change Log +## 1.0.14 - 2023.04.25 +### Fixed +* Wait not just for the database to be available, but also that the `info` table has been populated before proceeding with the `queue` container ([#2](https://github.com/nystudio107/spin-up-craft/issues/2)) + +### Changed +* Remove PHP platform version + ## 1.0.13 - 2023.03.30 ### Changed * Clean up the `Makefile` by using `docker compose` api diff --git a/composer.json b/composer.json index 1d9e34d..16324a5 100644 --- a/composer.json +++ b/composer.json @@ -16,9 +16,6 @@ "craftcms/plugin-installer": true, "yiisoft/yii2-composer": true }, - "sort-packages": true, - "platform": { - "php": "8.0.2" - } + "sort-packages": true } } diff --git a/docker-compose.yml b/docker-compose.yml index a0264d4..93fd9f0 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -71,7 +71,7 @@ services: *php-build command: /var/www/run_queue.sh depends_on: - - "php" + - "mysql" env_file: *env_file environment: