Files
Kol-Manager/docker/entrypoint.sh

68 lines
2.5 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
set -e
APP_DIR=/var/www/html
echo "──────────────────────────────────────────"
echo " KOL Manager – Container Start"
echo "──────────────────────────────────────────"
cd "$APP_DIR"
# ── 1. Bootstrap .env ───────────────────────
if [ ! -f .env ]; then
if [ -f .env.docker ]; then
cp .env.docker .env
echo "[env] Copied .env.docker → .env"
else
echo "[env] WARNING: No .env or .env.docker found!"
fi
fi
# ── 2. Generate APP_KEY if empty ────────────
if grep -qE '^APP_KEY=$' .env 2>/dev/null; then
echo "[key] Generating application key…"
php artisan key:generate --force --quiet
fi
# ── 3. Ensure SQLite database file exists ───
if [ ! -f database/database.sqlite ]; then
echo "[db] Creating SQLite database file…"
touch database/database.sqlite
fi
# ── 4. Fix ownership / permissions ──────────
chown -R www-data:www-data \
storage \
bootstrap/cache \
database
chmod -R 775 \
storage \
bootstrap/cache \
database
# ── 5. Discover packages (composer --no-scripts skips this) ──
echo "[packages] Discovering service providers…"
php artisan package:discover --ansi 2>/dev/null || true
# ── 6. Run migrations ─────────────────────────
echo "[migrate] Running database migrations…"
php artisan migrate --force --no-interaction
# ── 7. Create public storage symlink ──────────
echo "[storage] Creating public storage symlink…"
php artisan storage:link --quiet 2>/dev/null || true
# ── 8. Cache config / routes / views ─────────
echo "[optimize] Caching configuration…"
php artisan config:cache --quiet
php artisan route:cache --quiet
php artisan view:cache --quiet
echo "──────────────────────────────────────────"
echo " All checks passed. Starting services…"
echo "──────────────────────────────────────────"
# ── 9. Hand off to Supervisor ────────────────
exec supervisord -c /etc/supervisord.conf