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.
This commit is contained in:
@@ -8,7 +8,7 @@ services:
|
|||||||
APP_URL: ${APP_URL:-http://localhost}
|
APP_URL: ${APP_URL:-http://localhost}
|
||||||
APP_ENV: ${APP_ENV:-production}
|
APP_ENV: ${APP_ENV:-production}
|
||||||
APP_DEBUG: ${APP_DEBUG:-false}
|
APP_DEBUG: ${APP_DEBUG:-false}
|
||||||
APP_KEY: ${APP_KEY:-}
|
APP_KEY: ${APP_KEY}
|
||||||
DB_HOST: db
|
DB_HOST: db
|
||||||
DB_PORT: 3306
|
DB_PORT: 3306
|
||||||
DB_USER: ${DB_USER:-spota_user}
|
DB_USER: ${DB_USER:-spota_user}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ services:
|
|||||||
APP_URL: ${APP_URL:-http://localhost}
|
APP_URL: ${APP_URL:-http://localhost}
|
||||||
APP_ENV: ${APP_ENV:-production}
|
APP_ENV: ${APP_ENV:-production}
|
||||||
APP_DEBUG: ${APP_DEBUG:-false}
|
APP_DEBUG: ${APP_DEBUG:-false}
|
||||||
APP_KEY: ${APP_KEY:-}
|
APP_KEY: ${APP_KEY}
|
||||||
DB_HOST: ${DB_HOST:-db}
|
DB_HOST: ${DB_HOST:-db}
|
||||||
DB_PORT: ${DB_PORT:-3306}
|
DB_PORT: ${DB_PORT:-3306}
|
||||||
DB_USER: ${DB_USER:-spota_user}
|
DB_USER: ${DB_USER:-spota_user}
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ if [ -z "$(grep '^APP_KEY=base64:' .env || true)" ]; then
|
|||||||
php artisan key:generate --force
|
php artisan key:generate --force
|
||||||
fi
|
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 optimize:clear || true
|
||||||
php artisan config:cache || true
|
php artisan config:cache || true
|
||||||
php artisan route:cache || true
|
php artisan route:cache || true
|
||||||
|
|||||||
Reference in New Issue
Block a user