From e036139490cbfd80a160f45750e63f7a839c9b1a Mon Sep 17 00:00:00 2001 From: oguz ozturk Date: Sat, 10 Jan 2026 13:22:26 +0300 Subject: [PATCH] Complete deployment: Nginx + Supervisor + Auto-deploy --- DEPLOYMENT.md | 232 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 DEPLOYMENT.md diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md new file mode 100644 index 0000000..85413ec --- /dev/null +++ b/DEPLOYMENT.md @@ -0,0 +1,232 @@ +# πŸš€ Deployment Guide - Hosting Platform + +## πŸ“Š Server Information + +**Server IP**: `176.96.129.77` +**OS**: Ubuntu 24.04 LTS +**RAM**: 4GB +**CPU**: 4 cores + +--- + +## 🎯 Deployed Services + +### βœ… Core Services + +| Service | Port | URL | Status | +|---------|------|-----|--------| +| **Frontend (React)** | 3001 | http://176.96.129.77 | βœ… Running | +| **Backend API (Flask)** | 5000 | http://176.96.129.77/api | βœ… Running | +| **Gitea** | 3000 | http://176.96.129.77:3000 | βœ… Running | +| **PostgreSQL** | 5432 | localhost | βœ… Running | +| **Redis** | 6379 | localhost | βœ… Running | +| **Nginx** | 80 | http://176.96.129.77 | βœ… Running | + +### πŸ” Credentials + +**Gitea Admin**: +- Username: `hostadmin` +- Password: `HostAdmin2024!` +- Repository: http://176.96.129.77:3000/hostadmin/hosting-platform + +**PostgreSQL**: +- User: `hosting_user` +- Password: `HostingDB2024!` +- Database: `hosting_db` + +**Redis**: +- No password (localhost only) + +--- + +## πŸ—οΈ Architecture + +``` +Internet + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Nginx Reverse Proxy (Port 80) β”‚ +β”‚ - Frontend: / β”‚ +β”‚ - Backend API: /api β”‚ +β”‚ - Webhook: /webhook β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β–Ό β–Ό β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚Frontend β”‚ β”‚ Backend β”‚ β”‚ Gitea β”‚ +β”‚ :3001 β”‚ β”‚ :5000 β”‚ β”‚ :3000 β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β–Ό β–Ό + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚PostgreSQLβ”‚ β”‚ Redis β”‚ + β”‚ :5432 β”‚ β”‚ :6379 β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +--- + +## πŸ“ Directory Structure + +``` +/opt/hosting-platform/ +β”œβ”€β”€ backend/ +β”‚ β”œβ”€β”€ app/ +β”‚ β”‚ β”œβ”€β”€ __init__.py +β”‚ β”‚ β”œβ”€β”€ main.py +β”‚ β”‚ β”œβ”€β”€ config.py +β”‚ β”‚ β”œβ”€β”€ models/ +β”‚ β”‚ β”‚ β”œβ”€β”€ __init__.py +β”‚ β”‚ β”‚ └── domain.py +β”‚ β”‚ β”œβ”€β”€ services/ +β”‚ β”‚ β”‚ β”œβ”€β”€ __init__.py +β”‚ β”‚ β”‚ └── cloudflare_service.py +β”‚ β”‚ └── api/ +β”‚ β”œβ”€β”€ venv/ +β”‚ └── requirements.txt +β”œβ”€β”€ frontend/ +β”‚ β”œβ”€β”€ src/ +β”‚ β”‚ β”œβ”€β”€ App.jsx +β”‚ β”‚ β”œβ”€β”€ main.jsx +β”‚ β”‚ β”œβ”€β”€ pages/ +β”‚ β”‚ β”‚ β”œβ”€β”€ DomainSetup.jsx +β”‚ β”‚ β”‚ └── DomainList.jsx +β”‚ β”‚ └── services/ +β”‚ β”‚ └── api.js +β”‚ β”œβ”€β”€ package.json +β”‚ └── vite.config.js +└── deploy.sh +``` + +--- + +## πŸ”„ Auto-Deploy Workflow + +1. **Developer pushes code** to `main` branch +2. **Gitea webhook** triggers β†’ `POST http://176.96.129.77:5000/webhook/deploy` +3. **Backend receives webhook** β†’ Executes `/opt/hosting-platform/deploy.sh` +4. **Deploy script**: + - Pulls latest code from Git + - Installs dependencies + - Restarts services via Supervisor + +--- + +## πŸ› οΈ Management Commands + +### Supervisor (Process Management) + +```bash +# Check status +supervisorctl status + +# Restart services +supervisorctl restart hosting-backend +supervisorctl restart hosting-frontend + +# View logs +tail -f /var/log/hosting-backend.log +tail -f /var/log/hosting-frontend.log + +# Stop/Start +supervisorctl stop hosting-backend +supervisorctl start hosting-backend +``` + +### Nginx + +```bash +# Test configuration +nginx -t + +# Reload +systemctl reload nginx + +# Restart +systemctl restart nginx + +# View logs +tail -f /var/log/nginx/access.log +tail -f /var/log/nginx/error.log +``` + +### Database + +```bash +# Connect to PostgreSQL +psql -U hosting_user -d hosting_db + +# Connect to Redis +redis-cli +``` + +--- + +## πŸ§ͺ Testing + +### Health Check +```bash +curl http://176.96.129.77/health +``` + +### API Test +```bash +curl http://176.96.129.77/api/domains +``` + +### Frontend +Open browser: http://176.96.129.77 + +--- + +## πŸ“ Next Steps + +1. βœ… **Add SSL Certificate** (Let's Encrypt) +2. βœ… **Configure Domain Name** +3. βœ… **Set up Monitoring** (Prometheus/Grafana) +4. βœ… **Add Backup System** +5. βœ… **Implement Authentication** + +--- + +## πŸ†˜ Troubleshooting + +### Backend not starting +```bash +# Check logs +tail -f /var/log/hosting-backend.log + +# Check if port is in use +lsof -i :5000 + +# Restart +supervisorctl restart hosting-backend +``` + +### Frontend not loading +```bash +# Check logs +tail -f /var/log/hosting-frontend.log + +# Restart +supervisorctl restart hosting-frontend +``` + +### Database connection issues +```bash +# Check PostgreSQL status +systemctl status postgresql + +# Check connections +psql -U hosting_user -d hosting_db -c "SELECT * FROM pg_stat_activity;" +``` + +--- + +**Deployment Date**: 2026-01-10 +**Version**: 1.0.0 +**Deployed By**: Hosting Platform Team +