#!/bin/sh
set -e

mkdir -p storage/app/public storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache

if [ "$(id -u)" = "0" ]; then
    chown -R www-data:www-data storage bootstrap/cache
fi

php artisan storage:link --force 2>/dev/null || true
php artisan optimize

exec frankenphp run --config /etc/frankenphp/Caddyfile
