Compare commits

..

No commits in common. "733ecd66e71fdbf869b3d28d92d17a404c3d996b" and "f54467436a0985d32d602a3d9e61d888c740d20f" have entirely different histories.

4 changed files with 108 additions and 328 deletions

View File

@ -1,155 +0,0 @@
# 🚀 Deployment Summary - 2026-01-10
## ✅ Deployment Status: SUCCESS
### 📊 Deployment Details
- **Date**: 2026-01-10 12:26 UTC
- **Server**: 176.96.129.77 (argeict.net)
- **Git Commit**: f544674
- **Deployment Method**: SSH + Supervisor
---
## 🎯 What Was Deployed
### Backend Changes
- ✅ New Admin Routes (`/api/admin/cf-accounts`)
- ✅ DNS Nameserver Checker (`/api/dns/check-nameservers`)
- ✅ Encrypted CF Token Storage (Fernet encryption)
- ✅ Nameserver Service (dnspython integration)
- ✅ Database models updated (CloudflareAccount)
- ✅ New dependencies: `dnspython==2.4.2`
### Frontend Changes
- ✅ Admin CF Accounts Page
- ✅ CF Account Modal (Add/Edit)
- ✅ CF Token Guide Component
- ✅ Nameserver Instructions Component
- ✅ Domain Setup (New) Page
- ✅ Enhanced API service layer
---
## 🔧 Configuration Changes
### Environment Variables
```bash
ENCRYPTION_KEY=tThpEL7KeYwGSg9isM7LUbxv-Lju325c2gtIf56DHV4=
DATABASE_URL=postgresql://hosting:hosting_519c6c66a8e2695ce704ccba@localhost:5432/hosting
FLASK_ENV=production
SECRET_KEY=cfef4ad2f52832def87c20ebddb5067c44379c5ab366ebeb50217b5f484a92df
```
### Supervisor Configuration
- Updated to include all environment variables
- Added PYTHONPATH for proper module resolution
- Both services running successfully
---
## 🧪 Test Results
### API Health Checks
```json
✅ GET /health
{
"service": "hosting-platform-api",
"status": "ok"
}
✅ GET /api/admin/cf-accounts
{
"accounts": [],
"count": 0,
"status": "success"
}
✅ POST /api/dns/check-nameservers
{
"current_nameservers": ["ns1.google.com", ...],
"is_cloudflare": false,
"status": "error"
}
```
### Service Status
```
hosting-backend RUNNING pid 18670
hosting-frontend RUNNING pid 19155
```
---
## 🌐 Live URLs
- **Frontend**: https://argeict.net
- **API**: https://api.argeict.net
- **Gitea**: https://gitea.argeict.net
---
## 📝 Post-Deployment Tasks
### ✅ Completed
- [x] SSH key authentication configured
- [x] Database password updated
- [x] Environment variables configured
- [x] Supervisor config updated
- [x] Backend dependencies installed
- [x] Frontend built and deployed
- [x] Services restarted
- [x] Health checks passed
### 📋 Next Steps
1. Test CF Account Management in admin panel
2. Add first Cloudflare account
3. Test domain setup with new wizard
4. Monitor logs for any issues
5. Update documentation if needed
---
## 🔍 Troubleshooting
### View Logs
```bash
ssh root@176.96.129.77 'tail -f /var/log/hosting-backend.log'
```
### Restart Services
```bash
ssh root@176.96.129.77 'supervisorctl restart hosting-backend hosting-frontend'
```
### Check Service Status
```bash
ssh root@176.96.129.77 'supervisorctl status'
```
---
## 📚 Documentation Updates
- ✅ README.md updated with new features
- ✅ API endpoints documented
- ✅ Deployment script created (`deploy.sh`)
- ✅ Manual deployment instructions added
---
## 🎉 Success Metrics
- **Deployment Time**: ~15 minutes
- **Downtime**: ~30 seconds (service restart)
- **Issues Encountered**: 3 (all resolved)
1. Database password mismatch → Fixed
2. Missing dnspython dependency → Installed
3. Supervisor environment config → Updated
- **Final Status**: ✅ All systems operational
---
**Deployed by**: Augment Agent
**Deployment Script**: `./deploy.sh`
**Next Deployment**: Use `./deploy.sh` for automated deployment

View File

@ -4,7 +4,6 @@ Modern, otomatik DNS ve SSL yönetim platformu. Cloudflare entegrasyonu ile doma
## 📋 Özellikler ## 📋 Özellikler
### 🎯 Core Features
- ✅ **Cloudflare Entegrasyonu**: API token ile otomatik DNS yönetimi - ✅ **Cloudflare Entegrasyonu**: API token ile otomatik DNS yönetimi
- ✅ **DNS Önizleme**: Değişiklikleri uygulamadan önce görüntüleyin - ✅ **DNS Önizleme**: Değişiklikleri uygulamadan önce görüntüleyin
- ✅ **Otomatik SSL**: Cloudflare SSL/TLS yapılandırması - ✅ **Otomatik SSL**: Cloudflare SSL/TLS yapılandırması
@ -14,14 +13,6 @@ Modern, otomatik DNS ve SSL yönetim platformu. Cloudflare entegrasyonu ile doma
- ✅ **PostgreSQL**: Güvenilir veri saklama - ✅ **PostgreSQL**: Güvenilir veri saklama
- ✅ **Redis**: Hızlı cache ve session yönetimi - ✅ **Redis**: Hızlı cache ve session yönetimi
### 🆕 Yeni Özellikler (v2.0)
- ✨ **CF Account Management**: Admin panelden Cloudflare hesaplarını yönetin
- ✨ **Encrypted Token Storage**: API token'ları şifreli olarak saklama
- ✨ **DNS Nameserver Checker**: Gerçek zamanlı nameserver kontrolü
- ✨ **Advanced Domain Setup**: Gelişmiş domain kurulum sihirbazı
- ✨ **CF Token Guide**: Adım adım Cloudflare token oluşturma rehberi
- ✨ **Nameserver Instructions**: Kullanıcı dostu NS değiştirme talimatları
## 🏗️ Mimari ## 🏗️ Mimari
``` ```
@ -143,7 +134,6 @@ GET /health
POST /api/dns/validate-token POST /api/dns/validate-token
POST /api/dns/preview-changes POST /api/dns/preview-changes
POST /api/dns/apply-changes POST /api/dns/apply-changes
POST /api/dns/check-nameservers # 🆕 Nameserver kontrolü
``` ```
### Domain Management ### Domain Management
@ -155,14 +145,6 @@ PUT /api/domains/<id>
DELETE /api/domains/<id> DELETE /api/domains/<id>
``` ```
### Admin Endpoints (🆕)
```bash
GET /api/admin/cf-accounts # CF hesaplarını listele
POST /api/admin/cf-accounts # Yeni CF hesabı ekle
PUT /api/admin/cf-accounts/<id> # CF hesabını güncelle
DELETE /api/admin/cf-accounts/<id> # CF hesabını sil
```
## 📝 Lisans ## 📝 Lisans
MIT License - Detaylar için LICENSE dosyasına bakın. MIT License - Detaylar için LICENSE dosyasına bakın.
@ -173,58 +155,9 @@ Hosting Platform Team
--- ---
## 🚀 Deployment ## 🔄 Auto-Deploy
### Otomatik Deployment Bu proje otomatik deployment sistemi ile yapılandırılmıştır. `main` branch'e yapılan her push otomatik olarak sunucuya deploy edilir.
```bash
./deploy.sh
```
Bu script: **Webhook URL**: `http://176.96.129.77:5000/webhook/deploy`
1. ✅ Gitea'dan son kodu çeker
2. ✅ Backend dependencies yükler
3. ✅ Database migration yapar
4. ✅ Frontend build eder
5. ✅ Servisleri restart eder
6. ✅ Health check yapar
### Manuel Deployment
```bash
# SSH ile sunucuya bağlan
ssh root@176.96.129.77
# Proje dizinine git
cd /opt/hosting-platform
# Git pull
git pull origin main
# Backend güncelle
cd backend
source venv/bin/activate
pip install -r requirements.txt
python -c "from app.main import app, db; app.app_context().push(); db.create_all()"
# Frontend build
cd ../frontend
npm install
npm run build
# Servisleri restart et
supervisorctl restart hosting-backend hosting-frontend
```
### Servis Yönetimi
```bash
# Servis durumu
supervisorctl status
# Logları izle
tail -f /var/log/hosting-backend.log
# Servisleri restart et
supervisorctl restart hosting-backend hosting-frontend
```

View File

@ -162,46 +162,31 @@ def webhook_deploy():
"""Gitea webhook for auto-deployment""" """Gitea webhook for auto-deployment"""
import subprocess import subprocess
import os import os
from datetime import datetime
# Get webhook data # Verify webhook (optional: add secret validation)
data = request.json or {} data = request.json
# Log webhook event # Log webhook event
repo_name = data.get('repository', {}).get('name', 'unknown') print(f"📥 Webhook received: {data.get('repository', {}).get('name', 'unknown')}")
pusher = data.get('pusher', {}).get('username', 'unknown')
print(f"📥 Webhook received from {repo_name} by {pusher} at {datetime.now()}") # Trigger deployment script
# Trigger deployment script in background
try: try:
# Run deployment script asynchronously result = subprocess.run(
process = subprocess.Popen( ['/opt/hosting-platform/deploy.sh'],
['/opt/hosting-platform/deploy-local.sh'], capture_output=True,
stdout=subprocess.PIPE, text=True,
stderr=subprocess.PIPE, timeout=300
text=True
) )
# Don't wait for completion, return immediately
return jsonify({ return jsonify({
"status": "success", "status": "success",
"message": "Deployment triggered successfully", "message": "Deployment triggered",
"repository": repo_name, "output": result.stdout
"pusher": pusher, })
"timestamp": datetime.now().isoformat(),
"note": "Check /var/log/auto-deploy.log for deployment progress"
}), 202 # 202 Accepted
except FileNotFoundError:
return jsonify({
"status": "error",
"message": "Deployment script not found at /opt/hosting-platform/deploy-local.sh"
}), 500
except Exception as e: except Exception as e:
return jsonify({ return jsonify({
"status": "error", "status": "error",
"message": f"Failed to trigger deployment: {str(e)}" "message": str(e)
}), 500 }), 500

161
deploy.sh Executable file → Normal file
View File

@ -1,90 +1,106 @@
#!/bin/bash #!/bin/bash
# Hosting Platform Deployment Script # Deployment script for argeict.net server
# Usage: ./deploy.sh # This script deploys backend and frontend to the production server
set -e set -e # Exit on error
HOST="root@176.96.129.77" SERVER="root@argeict.net"
SSH_KEY="~/.ssh/id_rsa" BACKEND_DIR="/var/www/hosting-backend"
FRONTEND_DIR="/var/www/hosting-frontend"
echo "╔══════════════════════════════════════════════════════════════╗" echo "🚀 Starting deployment to argeict.net..."
echo "║ 🚀 Hosting Platform Deployment Script 🚀 ║"
echo "╚══════════════════════════════════════════════════════════════╝" # 1. Deploy Backend
echo "" echo ""
echo "📦 Deploying Backend..."
ssh $SERVER "mkdir -p $BACKEND_DIR"
# 1. Git Pull # Copy backend files
echo "📥 [1/6] Pulling latest code from Gitea..." rsync -avz --exclude='venv' --exclude='__pycache__' --exclude='*.pyc' --exclude='hosting.db' \
ssh -i $SSH_KEY $HOST << 'ENDSSH' backend/ $SERVER:$BACKEND_DIR/
cd /opt/hosting-platform
git pull origin main
ENDSSH
echo "✅ Git pull complete"
echo ""
# 2. Backend Dependencies # Copy .env.example as template
echo "📦 [2/6] Installing backend dependencies..." scp backend/.env.example $SERVER:$BACKEND_DIR/.env.example
ssh -i $SSH_KEY $HOST << 'ENDSSH'
cd /opt/hosting-platform/backend echo "✅ Backend files copied"
# Install dependencies and restart backend
ssh $SERVER << 'ENDSSH'
cd /var/www/hosting-backend
# Create venv if not exists
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi
# Activate venv and install dependencies
source venv/bin/activate source venv/bin/activate
pip install -q -r requirements.txt pip install --upgrade pip
ENDSSH pip install -r requirements.txt
echo "✅ Backend dependencies installed"
echo ""
# 3. Database Migration # Check if .env exists, if not create from example
echo "🗄️ [3/6] Running database migrations..." if [ ! -f ".env" ]; then
ssh -i $SSH_KEY $HOST << 'ENDSSH' echo "Creating .env file..."
cd /opt/hosting-platform/backend cp .env.example .env
source venv/bin/activate # Generate random encryption key
python -c "from app.main import app, db; app.app_context().push(); db.create_all()" ENCRYPTION_KEY=$(python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())")
ENDSSH sed -i "s|ENCRYPTION_KEY=.*|ENCRYPTION_KEY=$ENCRYPTION_KEY|" .env
echo "✅ Database migrations complete" echo "⚠️ Please edit .env file and set DATABASE_URL and other settings"
echo "" fi
# 4. Frontend Build # Initialize database if needed
echo "🎨 [4/6] Building frontend..." if [ ! -f "hosting.db" ]; then
ssh -i $SSH_KEY $HOST << 'ENDSSH' echo "Initializing database..."
cd /opt/hosting-platform/frontend python3 -c "from app.main import app, db; app.app_context().push(); db.create_all()"
npm install --silent fi
# Restart backend service (if using systemd)
if systemctl is-active --quiet hosting-backend; then
echo "Restarting backend service..."
sudo systemctl restart hosting-backend
else
echo "⚠️ Backend service not found. Please start manually or create systemd service."
fi
echo "✅ Backend deployed"
ENDSSH
# 2. Deploy Frontend
echo ""
echo "📦 Deploying Frontend..."
# Build frontend locally first
echo "Building frontend..."
cd frontend
npm install
npm run build npm run build
ENDSSH cd ..
echo "✅ Frontend built"
# Copy built files to server
ssh $SERVER "mkdir -p $FRONTEND_DIR"
rsync -avz --delete frontend/dist/ $SERVER:$FRONTEND_DIR/
echo "✅ Frontend deployed"
# 3. Update Nginx configuration (if needed)
echo "" echo ""
echo "🔧 Checking Nginx configuration..."
# 5. Restart Services ssh $SERVER << 'ENDSSH'
echo "🔄 [5/6] Restarting services..." # Reload nginx if config changed
ssh -i $SSH_KEY $HOST << 'ENDSSH' if nginx -t 2>/dev/null; then
supervisorctl restart hosting-backend hosting-frontend echo "Reloading Nginx..."
ENDSSH sudo systemctl reload nginx
sleep 3 echo "✅ Nginx reloaded"
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 else
echo "❌ API Health: FAILED" echo "⚠️ Nginx config test failed. Please check configuration."
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 fi
ENDSSH
echo "" echo ""
echo "╔══════════════════════════════════════════════════════════════╗" echo "✅ Deployment completed!"
echo "║ ✅ DEPLOYMENT SUCCESSFUL! ✅ ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo "" echo ""
echo "🌐 URLs:" echo "🌐 URLs:"
echo " Frontend: https://argeict.net" echo " Frontend: https://argeict.net"
@ -92,7 +108,8 @@ echo " API: https://api.argeict.net"
echo " Gitea: https://gitea.argeict.net" echo " Gitea: https://gitea.argeict.net"
echo "" echo ""
echo "📝 Next steps:" echo "📝 Next steps:"
echo " - Test the new features in the admin panel" echo " 1. SSH to server and check .env file: ssh $SERVER"
echo " - Check logs: ssh $HOST 'tail -f /var/log/hosting-backend.log'" echo " 2. Set DATABASE_URL in /var/www/hosting-backend/.env"
echo "" echo " 3. Check backend logs: journalctl -u hosting-backend -f"
echo " 4. Test API: curl https://api.argeict.net/health"