feat: Add Docker configuration for Laravel application, including services for portal, database, and cache with environment variables and entrypoint script enhancements.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cd /var/www/html
|
||||
|
||||
# Wait for MySQL to be ready (TCP check)
|
||||
if [ -n "$DB_HOST" ]; then
|
||||
echo "Waiting for database at $DB_HOST:${DB_PORT:-3306}..."
|
||||
until php -r "new PDO('mysql:host=$DB_HOST;port=${DB_PORT:-3306};dbname=$DB_DATABASE', '$DB_USERNAME', '$DB_PASSWORD');" 2>/dev/null; do
|
||||
sleep 2
|
||||
done
|
||||
echo "Database is ready."
|
||||
fi
|
||||
|
||||
# Ensure Laravel storage directories exist
|
||||
mkdir -p storage/framework/sessions \
|
||||
storage/framework/views \
|
||||
storage/framework/cache/data \
|
||||
storage/logs \
|
||||
bootstrap/cache
|
||||
chown -R www-data:www-data storage bootstrap/cache 2>/dev/null || true
|
||||
chmod -R 775 storage bootstrap/cache
|
||||
|
||||
# Run composer post-install scripts (skipped during build)
|
||||
php /usr/bin/composer dump-autoload --optimize --no-dev 2>/dev/null || true
|
||||
php artisan package:discover --ansi 2>/dev/null || true
|
||||
|
||||
# Laravel optimizations
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan view:cache
|
||||
php artisan storage:link --force 2>/dev/null || true
|
||||
|
||||
# Start PHP-FPM in background
|
||||
php-fpm -D
|
||||
|
||||
# Start Caddy in foreground
|
||||
exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
|
||||
Reference in New Issue
Block a user