diff --git a/.github/workflows/cypress-tests.yml b/.github/workflows/cypress-tests.yml index 157f54cd..0436c50b 100644 --- a/.github/workflows/cypress-tests.yml +++ b/.github/workflows/cypress-tests.yml @@ -59,7 +59,16 @@ jobs: done - name: Populate dxcc_entities table - run: curl "http://localhost/index.php/update/dxcc" + run: | + for i in `seq 1 10`; do + if curl -f "http://localhost/index.php/update/dxcc"; then + echo "DXCC entities populated successfully" + break + else + echo "Failed to populate DXCC entities, retrying in 10 seconds... (attempt $i/10)" + sleep 10 + fi + done - name: Run Cypress tests run: npx cypress run \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b7218da6..b26b53d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,8 @@ services: - ./:/var/www/html:rw command: ["./script.sh"] depends_on: - - db + db: + condition: service_healthy networks: - mynet @@ -28,5 +29,12 @@ services: - db_data:/var/lib/mysql networks: - mynet + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + timeout: 20s + retries: 10 + interval: 10s + start_period: 30s + volumes: db_data: {} diff --git a/script.sh b/script.sh index 6512444c..e713e866 100755 --- a/script.sh +++ b/script.sh @@ -79,6 +79,14 @@ rm -rf /install echo "Replacement complete." +# Wait for database to be ready +echo "Waiting for database to be ready..." +until mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "SELECT 1" > /dev/null 2>&1; do + echo "Database is not ready yet. Waiting 5 seconds..." + sleep 5 +done +echo "Database is ready!" + # Set Permissions chown -R root:www-data /var/www/html/application/config/ chown -R root:www-data /var/www/html/application/logs/