incr/docker/production/start-app.sh
2025-07-29 21:27:19 +02:00

29 lines
No EOL
812 B
Bash

#!/bin/sh
# Copy public files to shared volume if needed
cp -r /var/www/html/public/. /var/www/html/public_shared/ 2>/dev/null || true
# Create .env file if it doesn't exist
if [ ! -f /var/www/html/.env ]; then
cp /var/www/html/.env.example /var/www/html/.env 2>/dev/null || touch /var/www/html/.env
fi
# Wait for database to be ready
echo "Waiting for database..."
until php artisan tinker --execute="DB::connection()->getPdo();" 2>/dev/null; do
echo "Database not ready, waiting..."
sleep 2
done
echo "Database is ready!"
# Generate app key if not set
php artisan key:generate --force
# Laravel optimizations
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan migrate --force
# Start supervisor to manage nginx and php-fpm
supervisord -c /etc/supervisord.conf