Commit 718e4270 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix entrypoint: dump Docker env vars to .env before config:cache

CapRover passes env vars as container environment, but Laravel's
config:cache reads from .env file. Must dump env to .env first,
then generate APP_KEY if missing.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent ecdaefbf
...@@ -15,6 +15,16 @@ mkdir -p \ ...@@ -15,6 +15,16 @@ mkdir -p \
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
# Build .env from Docker env vars (CapRover passes them as container env)
: > .env
env | grep -E "^(APP_|DB_|LOG_|SESSION_|CACHE_|QUEUE_|FILESYSTEM_|BROADCAST_|MAIL_|TRUSTED_|BCRYPT_|PLATFORM_|ADMIN_|ACADEMY_|RUN_)" | sort | sed 's/=\(.*\)/="\1"/' >> .env
# Auto-generate APP_KEY if not set
if ! grep -q '^APP_KEY="base64:' .env 2>/dev/null; then
echo "==> Generating APP_KEY..."
php artisan key:generate --force --no-interaction
fi
# Create storage link if not exists # Create storage link if not exists
if [ ! -L public/storage ]; then if [ ! -L public/storage ]; then
php artisan storage:link --no-interaction php artisan storage:link --no-interaction
...@@ -29,6 +39,17 @@ php artisan event:cache ...@@ -29,6 +39,17 @@ php artisan event:cache
# Run pending migrations # Run pending migrations
php artisan migrate --force --no-interaction php artisan migrate --force --no-interaction
# First-deploy seeding (one-click install)
if [ "$RUN_SEED_ON_FIRST_DEPLOY" = "true" ]; then
# Check if organizations table is empty (fresh install)
ACADEMY_COUNT=$(php artisan tinker --execute="echo \App\Domain\Shared\Models\Academy::count();" 2>/dev/null | tail -1)
if [ "$ACADEMY_COUNT" = "0" ] || [ -z "$ACADEMY_COUNT" ]; then
echo "==> Fresh install detected. Running initial setup..."
php artisan el-captain:setup --no-interaction
echo "==> Initial setup complete."
fi
fi
# Publish Livewire assets # Publish Livewire assets
php artisan livewire:publish --assets 2>/dev/null || true php artisan livewire:publish --assets 2>/dev/null || true
......
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