diff --git a/Dockerfile b/Dockerfile index cfaf7523..4e3c04b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,5 +24,9 @@ RUN apt-get update && apt-get install -y \ && docker-php-ext-install xml \ && a2enmod rewrite +# Copy script.sh and make it executable +COPY script.sh /usr/local/bin/startup.sh +RUN sed -i 's/\r$//' /usr/local/bin/startup.sh && chmod +x /usr/local/bin/startup.sh + # Expose port 80 EXPOSE 80 \ No newline at end of file diff --git a/Dockerfile-db b/Dockerfile-db index ac550b76..e4ce0ce8 100644 --- a/Dockerfile-db +++ b/Dockerfile-db @@ -4,5 +4,9 @@ FROM mariadb:latest # Add the install.sql file to the docker image ADD install/assets/install.sql /docker-entrypoint-initdb.d +# Create a healthcheck script that uses mariadb-admin +RUN echo '#!/bin/bash\nmariadb-admin ping -h "localhost" --silent' > /usr/local/bin/healthcheck.sh \ + && chmod +x /usr/local/bin/healthcheck.sh + # Expose port 3306 EXPOSE 3306 \ No newline at end of file diff --git a/application/migrations/139_modify_eQSL_url.php b/application/migrations/139_modify_eQSL_url.php index 09e4fc37..e3f04afc 100644 --- a/application/migrations/139_modify_eQSL_url.php +++ b/application/migrations/139_modify_eQSL_url.php @@ -1,4 +1,4 @@ - /dev/null 2>&1; do - echo "Database is not ready yet. Waiting 5 seconds..." - sleep 5 -done -echo "Database is ready!" +echo "Connecting to: Host=$MYSQL_HOST, User=$MYSQL_USER, Database=$MYSQL_DATABASE" + +# Give the database a moment, then test connection once +sleep 2 +if mariadb -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -D"$MYSQL_DATABASE" -e "SELECT 1;" >/dev/null 2>&1; then + echo "Database is ready!" +else + echo "Database connection failed, but continuing anyway since healthcheck passed..." +fi # Set Permissions chown -R root:www-data /var/www/html/application/config/