From 797cb06f86037a1f89b0875aa5ed38307c70ed57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vi=CC=81ctor=20Falco=CC=81n?= Date: Mon, 29 Dec 2025 18:33:50 +0100 Subject: [PATCH] fix: auto-regenerate APP_KEY if invalid format (missing base64: prefix) --- docker/entrypoint.sh | 12 ++++++++---- templates/coolify/whisper-money.yaml | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 96f1502e..f4e636ed 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -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!" diff --git a/templates/coolify/whisper-money.yaml b/templates/coolify/whisper-money.yaml index a44dbf98..ef073489 100644 --- a/templates/coolify/whisper-money.yaml +++ b/templates/coolify/whisper-money.yaml @@ -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