Commit ebc3be78 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix entrypoint: ensure APP_KEY is in .env before config:cache

key:generate writes to .env, config:cache reads from .env — order matters.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent c4962789
...@@ -7,17 +7,18 @@ mkdir -p storage/framework/{cache/data,sessions,views} storage/logs bootstrap/ca ...@@ -7,17 +7,18 @@ mkdir -p storage/framework/{cache/data,sessions,views} storage/logs bootstrap/ca
chown -R www-data:www-data storage bootstrap/cache chown -R www-data:www-data storage bootstrap/cache
chmod -R 775 storage bootstrap/cache chmod -R 775 storage bootstrap/cache
# Write Docker env vars to .env (quoted) so config:cache picks them up # Build .env from Docker env vars (quoted to handle spaces)
: > .env : > .env
env | grep -E "^(APP_|DB_|LOG_|SESSION_|CACHE_|QUEUE_|FILESYSTEM_|BROADCAST_|MAIL_|CAPROVER_|PG_ADMIN_|SHARED_PG_|ELCAPTAIN_|TRUSTED_|BCRYPT_)" | sort | while IFS='=' read -r key value; do env | grep -E "^(APP_|DB_|LOG_|SESSION_|CACHE_|QUEUE_|FILESYSTEM_|BROADCAST_|MAIL_|CAPROVER_|PG_ADMIN_|SHARED_PG_|ELCAPTAIN_|TRUSTED_|BCRYPT_)" | sort | while IFS='=' read -r key value; do
echo "${key}=\"${value}\"" >> .env echo "${key}=\"${value}\"" >> .env
done done
# Generate APP_KEY if not set # Generate APP_KEY if not already set, then ensure it's in .env
if [ -z "$APP_KEY" ]; then if ! grep -q "^APP_KEY=\"base64:" .env 2>/dev/null; then
php artisan key:generate --force --no-interaction php artisan key:generate --force --no-interaction
fi fi
# Now cache config (reads from .env which has all values including APP_KEY)
php artisan config:cache php artisan config:cache
php artisan route:cache php artisan route:cache
php artisan view:cache php artisan view:cache
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment