diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index f4616f3..5ac09d3 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,43 +1,43 @@ #!/bin/bash -set -e cd /var/www/aigo -# Ensure storage directories exist (volume mount may hide image-created dirs) +# Ensure storage directories exist mkdir -p storage/framework/{cache/sessions,cache/data,views,testing} \ storage/logs \ - bootstrap/cache -chown -R www-data:www-data storage bootstrap/cache + bootstrap/cache 2>/dev/null || true +chown -R www-data:www-data storage bootstrap/cache 2>/dev/null || true + +# Generate app key if missing (required by Laravel) +php artisan key:generate --force 2>/dev/null || true # Wait for database if [ -n "$DB_HOST" ]; then echo "Waiting for database connection..." - for i in $(seq 1 30); do - if php -r " + DB_OK= + for i in $(seq 1 15); do + php -r " try { new PDO('mysql:host=$DB_HOST;port=${DB_PORT:-3306}', '$DB_USERNAME', '$DB_PASSWORD'); - echo 'ok'; + exit(0); } catch (PDOException \$e) { exit(1); } - " 2>/dev/null; then - echo "Database connected." - break - fi + " 2>/dev/null && DB_OK=1 && break echo "Waiting for database... attempt $i" sleep 2 done + if [ -n "$DB_OK" ]; then + echo "Database connected." + php artisan storage:link --force 2>/dev/null || true + php artisan migrate --force 2>/dev/null || true + else + echo "Warning: Database not available. Skipping migrations." + fi fi -# Create storage symlink -php artisan storage:link --force - -# Run migrations -php artisan migrate --force - -# Cache -php artisan config:cache -php artisan route:cache -php artisan view:cache +php artisan config:cache 2>/dev/null || true +php artisan route:cache 2>/dev/null || true +php artisan view:cache 2>/dev/null || true exec "$@" diff --git a/docker/apache/000-default.conf b/docker/apache/000-default.conf index f07930f..b3b84e7 100644 --- a/docker/apache/000-default.conf +++ b/docker/apache/000-default.conf @@ -1,3 +1,5 @@ +ServerName localhost + DocumentRoot /var/www/aigo/public