share-lt/cmd/docker-entrypoint.sh

38 lines
944 B
Bash
Raw Permalink Normal View History

2026-01-25 16:03:51 +00:00
#!/bin/sh
set -e
# Ensure APP_KEY is set and persisted
PERSISTED_KEY="/var/www/storage/.app_key"
if [ -z "$APP_KEY" ]; then
if [ -f "$PERSISTED_KEY" ]; then
echo "Using persisted APP_KEY from: $PERSISTED_KEY"
export APP_KEY=$(cat "$PERSISTED_KEY")
else
# Generate key, strip "base64:", and save
NEW_KEY=$(php artisan key:generate --show --no-interaction)
echo "Generated new APP_KEY to: $PERSISTED_KEY"
echo "$NEW_KEY" > "$PERSISTED_KEY"
export APP_KEY="$NEW_KEY"
fi
fi
# check to see if /var/www/database/database.sqlite exists
# if not, run migrations
if [ ! -f /var/www/database/database.sqlite ]; then
php artisan migrate --force
2026-01-25 16:03:51 +00:00
fi
# check to see if /var/www/public/storage exists
# if not, run storage:link
if [ ! -d /var/www/public/storage ]; then
php artisan storage:link
fi
php artisan config:clear
npm run build
2026-01-25 16:03:51 +00:00
# Start supervisord directly
2026-01-25 16:03:51 +00:00
exec "$@"