From 8a357e8cabf5add2901239bb5825325a75539054 Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Thu, 6 Mar 2025 18:35:57 -0600 Subject: [PATCH] refactor: use correct storage path for app key check --- config/app.php | 3 ++- docker-compose.yml | 3 +-- docker/entrypoint.sh | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/app.php b/config/app.php index f2a557f..0c90462 100644 --- a/config/app.php +++ b/config/app.php @@ -100,7 +100,8 @@ return [ 'cipher' => 'AES-256-CBC', - 'key' => env('APP_KEY') ?: when(file_exists('storage/app/.key'), fn () => trim(file_get_contents('storage/app/.key'))), + 'key' => env('APP_KEY') + ?: when(file_exists(storage_path('app/.key')), fn () => trim(file_get_contents(storage_path('app/.key')))), 'previous_keys' => [ ...array_filter( diff --git a/docker-compose.yml b/docker-compose.yml index dd10ba5..b60c755 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,6 @@ services: ports: - 8000:80 environment: # You can either use these properties OR an .env file. Do not use both! - APP_KEY: "" # Generate a key using `echo base64:$(openssl rand -base64 32)` APP_URL: "http://localhost:8000" ASSET_URL: "http://localhost:8000" DB_CONNECTION: mysql @@ -25,7 +24,7 @@ services: REDIS_HOST: investbrain-redis volumes: - investbrain-storage:/var/app/storage # You can use a volume... - # - /path/to/storage:/var/app/storage # ...or you can use a path on host + # - /path/to/storage:/var/app/storage:delegated # ...or you can use a path on host depends_on: - mysql - redis diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 7ca0c12..552e84d 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -14,11 +14,13 @@ mkdir -p storage/framework/cache \ storage/app \ storage/logs +echo -e "\n > Storage directory scaffolding is OK... " + # Ensure storage directory is permissioned for www-data chmod -R 775 storage chown -R www-data:www-data storage -echo -e "\n > Storage directory scaffolding is OK... " +echo -e "\n > Permissions are OK... " # Ensure app key exists / generate if required KEY_FILE="storage/app/.key" @@ -36,7 +38,7 @@ if [ -z "$APP_KEY" ] && [ ! -s "$KEY_FILE" ]; then export APP_KEY="$(php artisan key:generate --show)" - echo -e "\n > Oops! The required APP_KEY configuration is missing! Generated app key and saved in $KEY_FILE ." + echo -e "\n > Oops! The required APP_KEY configuration is missing! Generated app key and saved in $KEY_FILE" echo "$APP_KEY" > "$KEY_FILE"