fix: auto-regenerate APP_KEY if invalid format (missing base64: prefix)

This commit is contained in:
Víctor Falcón 2025-12-29 18:33:50 +01:00
parent a7ee776af7
commit 797cb06f86
2 changed files with 9 additions and 5 deletions

View File

@ -13,12 +13,16 @@ mkdir -p /app/storage/logs
chown -R www-data:www-data /app/storage
chmod -R 775 /app/storage
# Auto-generate APP_KEY if not set
if [ -z "$APP_KEY" ]; then
echo "No APP_KEY found, generating one..."
# Auto-generate APP_KEY if not set or invalid (must start with "base64:")
if [ -z "$APP_KEY" ] || [[ ! "$APP_KEY" =~ ^base64: ]]; then
if [ -n "$APP_KEY" ]; then
echo "APP_KEY is set but invalid (must start with 'base64:')"
else
echo "No APP_KEY found"
fi
echo "Generating new APP_KEY..."
APP_KEY=$(php artisan key:generate --show)
export APP_KEY
echo "Generated APP_KEY: $APP_KEY"
echo ""
echo "=================================================="
echo "IMPORTANT: Save this key in your environment!"

View File

@ -12,8 +12,8 @@ services:
- APP_NAME=Whisper Money
- APP_ENV=production
- APP_DEBUG=false
- APP_KEY=${SERVICE_BASE64_64_APPKEY}
- APP_URL=${SERVICE_FQDN_WHISPERMONEY_80}
# APP_KEY is auto-generated on first startup if not provided
- DB_CONNECTION=mysql
- DB_HOST=mysql
- DB_PORT=3306