#!/bin/sh set -e cd /var/www/html # Laravel needs a .env file to exist; values come from container env. [ -f .env ] || : > .env # Storage volume mounts can come up empty — ensure tree exists + writable. mkdir -p storage/framework/cache storage/framework/sessions storage/framework/views \ storage/logs storage/app/public bootstrap/cache chmod -R 775 storage bootstrap/cache 2>/dev/null || true chown -R www-data:www-data storage bootstrap/cache 2>/dev/null || true # Public storage symlink (idempotent). if [ ! -L public/storage ] && [ -d storage/app/public ]; then php artisan storage:link 2>/dev/null || true fi exec "$@"