Point APP_DIR at /home/hausdesign/preregister and run artisan/composer via explicit PHP and Composer binaries. Made-with: Cursor
80 lines
2.3 KiB
Bash
80 lines
2.3 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
# ──────────────────────────────────────────
|
|
# PreRegister Deploy Script
|
|
# Run on VPS: ./deploy.sh [tag]
|
|
# Examples:
|
|
# ./deploy.sh → deploys latest main
|
|
# ./deploy.sh v1.2.0 → deploys specific tag
|
|
# ──────────────────────────────────────────
|
|
|
|
APP_DIR="/home/hausdesign/preregister"
|
|
PHP="/usr/local/php84/bin/php"
|
|
COMPOSER="/usr/local/bin/composer"
|
|
TAG="${1:-}"
|
|
|
|
echo "══════════════════════════════════════"
|
|
echo " PreRegister — Deploy"
|
|
echo "══════════════════════════════════════"
|
|
|
|
cd "$APP_DIR"
|
|
|
|
# 1. Maintenance mode
|
|
echo "→ Enabling maintenance mode..."
|
|
$PHP artisan down --retry=30 || true
|
|
|
|
# 2. Pull latest code
|
|
echo "→ Pulling from Gitea..."
|
|
git fetch --all --tags
|
|
|
|
if [ -n "$TAG" ]; then
|
|
echo "→ Checking out tag: $TAG"
|
|
git checkout "$TAG"
|
|
else
|
|
echo "→ Checking out latest main"
|
|
git checkout main
|
|
git pull origin main
|
|
fi
|
|
|
|
# 3. Install PHP dependencies
|
|
echo "→ Installing Composer dependencies..."
|
|
$PHP $COMPOSER install --no-dev --optimize-autoloader --no-interaction
|
|
|
|
# 4. Install Node dependencies and build
|
|
echo "→ Installing npm packages..."
|
|
npm ci --production=false
|
|
|
|
echo "→ Building frontend assets..."
|
|
npm run build
|
|
|
|
# 5. Run migrations
|
|
echo "→ Running migrations..."
|
|
$PHP artisan migrate --force
|
|
|
|
# 6. Clear and rebuild caches
|
|
echo "→ Clearing caches..."
|
|
$PHP artisan config:cache
|
|
$PHP artisan route:cache
|
|
$PHP artisan view:cache
|
|
$PHP artisan event:cache
|
|
|
|
# 7. Restart queue (process any pending jobs with new code)
|
|
echo "→ Restarting queue workers..."
|
|
$PHP artisan queue:restart
|
|
|
|
# 8. Storage link (idempotent)
|
|
$PHP artisan storage:link 2>/dev/null || true
|
|
|
|
# 9. Disable maintenance mode
|
|
echo "→ Going live!"
|
|
$PHP artisan up
|
|
|
|
echo ""
|
|
echo "══════════════════════════════════════"
|
|
if [ -n "$TAG" ]; then
|
|
echo " Deployed: $TAG"
|
|
else
|
|
echo " Deployed: main (latest)"
|
|
fi
|
|
echo "══════════════════════════════════════" |