Docker_Laravel/start.sh

20 lines
552 B
Bash
Executable File

#!/bin/sh
sleep 10
# Check if .env file exists, if not create it from .env.example
if [ ! -f /var/www/html/.env ]; then
cp /var/www/html/.env.example /var/www/html/.env
fi
# Check if APP_KEY is missing or empty
if [ -z "$(grep '^APP_KEY=.\+' /var/www/html/.env)" ]; then
echo "Generating APP_KEY..."
php artisan key:generate || { echo "Failed to generate APP_KEY"; exit 1; }
fi
# Run migrations
php artisan migrate --force || { echo "Failed to run migrations"; exit 1; }
# Start PHP-FPM
php-fpm || { echo "Failed to start PHP-FPM"; exit 1; }