Files
spota-dev/docker/laravel-entrypoint.sh
Power BI Dev 9a3849c04f Fix Laravel APP_KEY handling in Docker
Export the generated Laravel app key before starting Apache so deployments without an explicit APP_KEY do not fail with a 500 MissingAppKeyException.
2026-05-03 19:20:28 +07:00

62 lines
1.3 KiB
Bash

#!/usr/bin/env sh
set -e
cd /var/www/html
mkdir -p storage/app/files storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache public/build
if [ ! -f .env ]; then
cat > .env <<EOF
APP_NAME="SPOTA Rebuild"
APP_ENV=${APP_ENV:-production}
APP_KEY=${APP_KEY:-}
APP_DEBUG=${APP_DEBUG:-false}
APP_URL=${APP_URL:-http://localhost}
APP_LOCALE=id
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=id_ID
LOG_CHANNEL=stack
LOG_STACK=single
LOG_LEVEL=${LOG_LEVEL:-debug}
DB_CONNECTION=mysql
DB_HOST=${DB_HOST:-db}
DB_PORT=${DB_PORT:-3306}
DB_DATABASE=${DB_NAME:-spota_spotadb}
DB_USERNAME=${DB_USER:-spota_user}
DB_PASSWORD=${DB_PASSWORD:-spota_password}
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=${SESSION_DOMAIN:-}
CACHE_STORE=file
QUEUE_CONNECTION=sync
FILESYSTEM_DISK=local
VITE_APP_NAME="SPOTA Rebuild"
EOF
fi
if [ -z "$(grep '^APP_KEY=base64:' .env || true)" ]; then
php artisan key:generate --force
fi
APP_KEY_VALUE="$(grep '^APP_KEY=' .env | tail -n 1 | cut -d '=' -f 2-)"
if [ -n "$APP_KEY_VALUE" ]; then
export APP_KEY="$APP_KEY_VALUE"
fi
php artisan optimize:clear || true
php artisan config:cache || true
php artisan route:cache || true
php artisan view:cache || true
chown -R www-data:www-data storage bootstrap/cache public/build 2>/dev/null || true
exec "$@"