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
### 🎯 Core Features
- ✅ **Cloudflare Entegrasyonu**: API token ile otomatik DNS yönetimi
- ✅ **DNS Önizleme**: Değişiklikleri uygulamadan önce görüntüleyin
- ✅ **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
- ✅ **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
```
@ -143,7 +134,6 @@ GET /health
POST /api/dns/validate-token
POST /api/dns/preview-changes
POST /api/dns/apply-changes
POST /api/dns/check-nameservers # 🆕 Nameserver kontrolü
```
### Domain Management
@ -155,14 +145,6 @@ PUT /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
MIT License - Detaylar için LICENSE dosyasına bakın.
@ -173,58 +155,9 @@ Hosting Platform Team
---
## 🚀 Deployment
## 🔄 Auto-Deploy
### Otomatik Deployment
```bash
./deploy.sh
```
Bu proje otomatik deployment sistemi ile yapılandırılmıştır. `main` branch'e yapılan her push otomatik olarak sunucuya deploy edilir.
Bu script:
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
```
**Webhook URL**: `http://176.96.129.77:5000/webhook/deploy`

View File

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

161
deploy.sh Executable file → Normal file
View File

@ -1,90 +1,106 @@
#!/bin/bash
# Hosting Platform Deployment Script
# Usage: ./deploy.sh
# Deployment script for argeict.net server
# This script deploys backend and frontend to the production server
set -e
set -e # Exit on error
HOST="root@176.96.129.77"
SSH_KEY="~/.ssh/id_rsa"
SERVER="root@argeict.net"
BACKEND_DIR="/var/www/hosting-backend"
FRONTEND_DIR="/var/www/hosting-frontend"
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ 🚀 Hosting Platform Deployment Script 🚀 ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo "🚀 Starting deployment to argeict.net..."
# 1. Deploy Backend
echo ""
echo "📦 Deploying Backend..."
ssh $SERVER "mkdir -p $BACKEND_DIR"
# 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 ""
# Copy backend files
rsync -avz --exclude='venv' --exclude='__pycache__' --exclude='*.pyc' --exclude='hosting.db' \
backend/ $SERVER:$BACKEND_DIR/
# 2. Backend Dependencies
echo "📦 [2/6] Installing backend dependencies..."
ssh -i $SSH_KEY $HOST << 'ENDSSH'
cd /opt/hosting-platform/backend
# Copy .env.example as template
scp backend/.env.example $SERVER:$BACKEND_DIR/.env.example
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
pip install -q -r requirements.txt
ENDSSH
echo "✅ Backend dependencies installed"
echo ""
pip install --upgrade pip
pip install -r requirements.txt
# 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 ""
# Check if .env exists, if not create from example
if [ ! -f ".env" ]; then
echo "Creating .env file..."
cp .env.example .env
# Generate random encryption key
ENCRYPTION_KEY=$(python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())")
sed -i "s|ENCRYPTION_KEY=.*|ENCRYPTION_KEY=$ENCRYPTION_KEY|" .env
echo "⚠️ Please edit .env file and set DATABASE_URL and other settings"
fi
# 4. Frontend Build
echo "🎨 [4/6] Building frontend..."
ssh -i $SSH_KEY $HOST << 'ENDSSH'
cd /opt/hosting-platform/frontend
npm install --silent
# Initialize database if needed
if [ ! -f "hosting.db" ]; then
echo "Initializing database..."
python3 -c "from app.main import app, db; app.app_context().push(); db.create_all()"
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
ENDSSH
echo "✅ Frontend built"
cd ..
# 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 "🔧 Checking Nginx configuration..."
# 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"
ssh $SERVER << 'ENDSSH'
# Reload nginx if config changed
if nginx -t 2>/dev/null; then
echo "Reloading Nginx..."
sudo systemctl reload nginx
echo "✅ Nginx reloaded"
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
echo "⚠️ Nginx config test failed. Please check configuration."
fi
ENDSSH
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ ✅ DEPLOYMENT SUCCESSFUL! ✅ ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo "✅ Deployment completed!"
echo ""
echo "🌐 URLs:"
echo " Frontend: https://argeict.net"
@ -92,7 +108,8 @@ 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 ""
echo " 1. SSH to server and check .env file: ssh $SERVER"
echo " 2. Set DATABASE_URL in /var/www/hosting-backend/.env"
echo " 3. Check backend logs: journalctl -u hosting-backend -f"
echo " 4. Test API: curl https://api.argeict.net/health"