browser-sec-lab/docker/php/entrypoint.sh
2026-07-05 17:49:52 +03:30

38 lines
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
echo "[+] Starting Laravel Initialization Script..."
# ۱. ساخت پوشه‌های ساختاری لاراول
echo "[+] Ensuring Laravel storage and cache directories exist..."
mkdir -p storage/framework/cache/data \
storage/framework/views \
storage/framework/sessions \
storage/logs \
bootstrap/cache
# ۲. مدیریت فایل .env
if [ ! -f .env ]; then
echo "[+] .env file not found, creating from .env.example..."
cp .env.example .env
fi
# ۳. تولید کلید اپلیکیشن
if ! grep -q "APP_KEY=base64:" .env; then
echo "[+] Generating application key..."
php artisan key:generate --force
fi
# ۴. پاک‌سازی کش (با ساختار درست || true برای نادیده گرفتن تاخیر دیتابیس)
echo "[+] Clearing stale Laravel configurations and views..."
php artisan config:clear || true
php artisan view:clear || true
php artisan cache:clear || true
# ۵. تنظیم دسترسی‌ها
echo "[+] Setting permissions for storage and bootstrap/cache..."
chmod -R 777 storage bootstrap/cache
echo "[+] Laravel is ready! Launching application..."
exec "$@"