hosting-platform/DEPLOYMENT.md

5.2 KiB

🚀 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:

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)

# 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

# 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

# Connect to PostgreSQL
psql -U hosting_user -d hosting_db

# Connect to Redis
redis-cli

🧪 Testing

Health Check

curl http://176.96.129.77/health

API Test

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

# 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

# Check logs
tail -f /var/log/hosting-frontend.log

# Restart
supervisorctl restart hosting-frontend

Database connection issues

# 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