99 lines
3.0 KiB
Bash
Executable File
99 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Hosting Platform Deployment Script
|
|
# Usage: ./deploy.sh
|
|
|
|
set -e
|
|
|
|
HOST="root@176.96.129.77"
|
|
SSH_KEY="~/.ssh/id_rsa"
|
|
|
|
echo "╔══════════════════════════════════════════════════════════════╗"
|
|
echo "║ 🚀 Hosting Platform Deployment Script 🚀 ║"
|
|
echo "╚══════════════════════════════════════════════════════════════╝"
|
|
echo ""
|
|
|
|
# 1. Git Pull
|
|
echo "📥 [1/6] Pulling latest code from Gitea..."
|
|
ssh -i $SSH_KEY $HOST << 'ENDSSH'
|
|
cd /opt/hosting-platform
|
|
git pull origin main
|
|
ENDSSH
|
|
echo "✅ Git pull complete"
|
|
echo ""
|
|
|
|
# 2. Backend Dependencies
|
|
echo "📦 [2/6] Installing backend dependencies..."
|
|
ssh -i $SSH_KEY $HOST << 'ENDSSH'
|
|
cd /opt/hosting-platform/backend
|
|
source venv/bin/activate
|
|
pip install -q -r requirements.txt
|
|
ENDSSH
|
|
echo "✅ Backend dependencies installed"
|
|
echo ""
|
|
|
|
# 3. Database Migration
|
|
echo "🗄️ [3/6] Running database migrations..."
|
|
ssh -i $SSH_KEY $HOST << 'ENDSSH'
|
|
cd /opt/hosting-platform/backend
|
|
source venv/bin/activate
|
|
python -c "from app.main import app, db; app.app_context().push(); db.create_all()"
|
|
ENDSSH
|
|
echo "✅ Database migrations complete"
|
|
echo ""
|
|
|
|
# 4. Frontend Build
|
|
echo "🎨 [4/6] Building frontend..."
|
|
ssh -i $SSH_KEY $HOST << 'ENDSSH'
|
|
cd /opt/hosting-platform/frontend
|
|
npm install --silent
|
|
npm run build
|
|
ENDSSH
|
|
echo "✅ Frontend built"
|
|
echo ""
|
|
|
|
# 5. Restart Services
|
|
echo "🔄 [5/6] Restarting services..."
|
|
ssh -i $SSH_KEY $HOST << 'ENDSSH'
|
|
supervisorctl restart hosting-backend hosting-frontend
|
|
ENDSSH
|
|
sleep 3
|
|
echo "✅ Services restarted"
|
|
echo ""
|
|
|
|
# 6. Health Check
|
|
echo "🏥 [6/6] Running health checks..."
|
|
sleep 2
|
|
|
|
HEALTH=$(curl -s https://api.argeict.net/health)
|
|
if echo "$HEALTH" | grep -q "ok"; then
|
|
echo "✅ API Health: OK"
|
|
else
|
|
echo "❌ API Health: FAILED"
|
|
exit 1
|
|
fi
|
|
|
|
ADMIN=$(curl -s https://api.argeict.net/api/admin/cf-accounts)
|
|
if echo "$ADMIN" | grep -q "success"; then
|
|
echo "✅ Admin Endpoints: OK"
|
|
else
|
|
echo "❌ Admin Endpoints: FAILED"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "╔══════════════════════════════════════════════════════════════╗"
|
|
echo "║ ✅ DEPLOYMENT SUCCESSFUL! ✅ ║"
|
|
echo "╚══════════════════════════════════════════════════════════════╝"
|
|
echo ""
|
|
echo "🌐 URLs:"
|
|
echo " Frontend: https://argeict.net"
|
|
echo " API: https://api.argeict.net"
|
|
echo " Gitea: https://gitea.argeict.net"
|
|
echo ""
|
|
echo "📝 Next steps:"
|
|
echo " - Test the new features in the admin panel"
|
|
echo " - Check logs: ssh $HOST 'tail -f /var/log/hosting-backend.log'"
|
|
echo ""
|
|
|