#!/bin/sh set -e cd /var/www/html # Install PHP dependencies on first boot (the app is bind-mounted from ./src) if [ ! -f vendor/autoload.php ]; then echo "vendor/ missing - running composer install..." composer install --no-interaction --prefer-dist --no-progress fi # Compile Tailwind CSS if [ -f resources/css/app.css ]; then echo "Building Tailwind CSS..." tailwindcss -i resources/css/app.css -o public/css/app.css --minify fi # Wait for the database to accept connections echo "Waiting for database at ${DB_HOST}:${DB_PORT}..." until php -r ' try { new PDO( "mysql:host=" . getenv("DB_HOST") . ";port=" . getenv("DB_PORT"), getenv("DB_USERNAME"), getenv("DB_PASSWORD"), [PDO::ATTR_TIMEOUT => 3] ); } catch (Throwable $e) { exit(1); } ' 2>/dev/null; do echo " ...database not ready, retrying" sleep 2 done echo "Database is up." php artisan migrate --force php artisan db:seed --force # Make runtime directories writable by the web server. # chown can be a no-op or fail on Windows bind mounts - never fatal. chown -R www-data:www-data storage bootstrap/cache 2>/dev/null || true chmod -R ugo+rwX storage bootstrap/cache 2>/dev/null || true exec "$@"