fedi-feed-router/docker/production/start-app.sh

34 lines
978 B
Bash
Raw Normal View History

2025-08-02 03:22:09 +02:00
#!/bin/sh
# 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..."
while ! mysql -h db -u ffr_user -pffr_password --connect-timeout=2 -e "SELECT 1" >/dev/null 2>&1; do
echo "Database not ready, waiting..."
sleep 1
done
echo "Database connection established!"
# Generate app key if not set
if ! grep -q "APP_KEY=base64:" /var/www/html/.env; then
php artisan key:generate --force
fi
# Laravel optimizations for production
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Run migrations
php artisan migrate --force
# Run seeders (only if needed for production data)
php artisan db:seed --force --class=PlatformInstanceSeeder
php artisan db:seed --force --class=SettingsSeeder
# Start supervisor to manage nginx and php-fpm
supervisord -c /etc/supervisord.conf