diff --git a/Dockerfile b/Dockerfile index 4a0ee6a..c90bfed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,8 @@ RUN apt-get update && apt-get install -y \ libxml2-dev \ zip \ unzip \ - procps + procps \ + mariadb-client RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer @@ -21,7 +22,6 @@ RUN composer install --no-scripts --no-interaction RUN chown -R www-data:www-data /var/www/html RUN chmod -R 775 /var/www/html/storage -# Install PDO MySQL (Fix for "Could not find driver" error) RUN docker-php-ext-install pdo pdo_mysql COPY entrypoint.sh /usr/local/bin/entrypoint.sh diff --git a/docker-compose.yml b/docker-compose.yml index 763eae8..3faf209 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,10 +7,10 @@ services: volumes: - mysql-data:/var/lib/mysql healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-prootpassword"] interval: 10s timeout: 5s - retries: 5 + retries: 10 restart: unless-stopped laravel: @@ -41,7 +41,7 @@ services: laravel: condition: service_healthy ports: - - "8080:80" + - "80:80" # Changed from 8080 to 80 volumes: - ./nginx.conf:/etc/nginx/conf.d/default.conf - ./laravel:/var/www/html diff --git a/entrypoint.sh b/entrypoint.sh index f4745e6..fd6c4f3 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,8 +1,19 @@ #!/bin/bash -# Fix ownership and permissions for storage directories +set -e + +# Fix ownership and permissions chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache + +# Wait for MySQL to be ready +echo "Waiting for MySQL to be ready..." +while ! mysqladmin ping -h"mysql" -u"root" -p"rootpassword" --silent; do + sleep 1 +done +echo "MySQL is ready!" + # Run migrations php artisan migrate --force + # Start PHP-FPM exec "$@"