Clean up tunnel infrastructure and migrate to Gitea
Some checks failed
Deploy to Production Server / Deploy to 178.63.127.19 (push) Has been cancelled

This commit is contained in:
2026-01-10 23:54:31 +00:00
parent 63c578b0ae
commit 53d0c89d17
8 changed files with 2220 additions and 172 deletions

351
DEPLOY_NOW.md Normal file
View File

@@ -0,0 +1,351 @@
# 🚀 Quick Deployment Guide for TurboTrades
**Server:** 178.63.127.19
**Repository:** git.turbotrades.dev/iDefineHD/TurboTrades
**User:** root (or your SSH user)
---
## ⚡ Super Quick Deploy (5 Minutes)
### 1⃣ **Push Your Code**
```bash
cd C:\Users\dg-ho\Documents\projects\TurboTrades
git add .
git commit -m "feat: Complete admin panel with deployment setup"
git push origin main
```
### 2⃣ **Setup Server (One-Time)**
SSH into your server:
```bash
ssh root@178.63.127.19
```
Run the automated setup script:
```bash
# Download and run setup script
curl -o setup.sh https://git.turbotrades.dev/iDefineHD/TurboTrades/raw/branch/main/scripts/setup-server.sh
chmod +x setup.sh
sudo ./setup.sh
```
**OR** manually setup:
```bash
# Update system
apt update && apt upgrade -y
# Install Node.js 20
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs
# Install MongoDB
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb-server-7.0.gpg
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list
apt update && apt install -y mongodb-org
systemctl start mongod && systemctl enable mongod
# Install PM2
npm install -g pm2
# Install Nginx
apt install -y nginx
systemctl start nginx && systemctl enable nginx
# Create directory
mkdir -p /var/www/turbotrades
cd /var/www/turbotrades
# Clone repository
git clone https://git.turbotrades.dev/iDefineHD/TurboTrades.git .
```
### 3⃣ **Configure Environment**
Create `.env` file on server:
```bash
nano /var/www/turbotrades/.env
```
Add this configuration:
```env
# Server
NODE_ENV=production
PORT=3000
HOST=0.0.0.0
# Database
MONGODB_URI=mongodb://localhost:27017/turbotrades
# Secrets (CHANGE THESE!)
SESSION_SECRET=your-random-secret-here-change-this-123456789
JWT_SECRET=your-jwt-secret-here-change-this-987654321
JWT_ACCESS_EXPIRY=15m
JWT_REFRESH_EXPIRY=7d
# Steam API
STEAM_API_KEY=your-steam-api-key
STEAM_RETURN_URL=http://178.63.127.19:3000/auth/steam/return
# CORS
CORS_ORIGIN=http://178.63.127.19
# Admin Steam IDs (Your Steam ID)
ADMIN_STEAM_IDS=76561198000000000
# Optional: Steam Bot
STEAM_BOT_USERNAME=
STEAM_BOT_PASSWORD=
STEAM_BOT_SHARED_SECRET=
STEAM_BOT_IDENTITY_SECRET=
```
Save with `Ctrl+X`, then `Y`, then `Enter`
### 4⃣ **Deploy Application**
```bash
cd /var/www/turbotrades
# Install dependencies
npm ci --production
# Build frontend
cd frontend
npm ci
npm run build
cd ..
# Start with PM2
pm2 start ecosystem.config.js --env production
pm2 save
pm2 startup
```
### 5⃣ **Configure Nginx (Optional but Recommended)**
```bash
nano /etc/nginx/sites-available/turbotrades
```
Paste this:
```nginx
server {
listen 80;
server_name 178.63.127.19;
location / {
root /var/www/turbotrades/frontend/dist;
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
location /ws {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /auth {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
```
Enable and restart:
```bash
ln -s /etc/nginx/sites-available/turbotrades /etc/nginx/sites-enabled/
nginx -t
systemctl restart nginx
```
### 6⃣ **Configure GitHub Actions (Automatic Deployments)**
1. Go to your repository settings/secrets (Gitea CI/CD settings)
2. Click **"New repository secret"** or equivalent
3. Add these secrets:
| Name | Value |
|------|-------|
| `SERVER_HOST` | `178.63.127.19` |
| `SERVER_USER` | `root` (or your SSH username) |
| `SERVER_PORT` | `22` |
| `SSH_PRIVATE_KEY` | Your SSH private key (see below) |
| `DEPLOY_PATH` | `/var/www/turbotrades` |
#### Generate SSH Key for Deployment:
On your server:
```bash
ssh-keygen -t ed25519 -C "deploy@turbotrades" -f ~/.ssh/turbotrades_deploy
cat ~/.ssh/turbotrades_deploy.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/turbotrades_deploy # Copy this for GitHub Secret
```
---
## 🎯 After Setup - How to Deploy
### Automatic Deployment (Recommended):
```bash
# Just push to main branch
git add .
git commit -m "Your changes"
git push origin main
```
GitHub Actions will automatically:
✅ Build frontend
✅ Deploy to server
✅ Restart PM2
✅ Health check
Watch progress in your Gitea repository's Actions tab
### Manual Deployment:
```bash
ssh root@178.63.127.19
cd /var/www/turbotrades
git pull origin main
npm ci --production
cd frontend && npm ci && npm run build && cd ..
pm2 restart turbotrades
pm2 logs turbotrades
```
---
## 🔍 Check Status
### From Your Computer:
```bash
# Check if site is running
curl http://178.63.127.19:3000/api/health
# Check PM2 status via SSH
ssh root@178.63.127.19 "pm2 status"
# Check logs via SSH
ssh root@178.63.127.19 "pm2 logs turbotrades --lines 50"
```
### On Server:
```bash
ssh root@178.63.127.19
# Check PM2
pm2 status
pm2 logs turbotrades
# Check MongoDB
systemctl status mongod
# Check Nginx
systemctl status nginx
# Check application logs
tail -f /var/www/turbotrades/logs/pm2-combined.log
```
---
## 🚨 Quick Fixes
### App Not Starting:
```bash
ssh root@178.63.127.19
cd /var/www/turbotrades
pm2 logs turbotrades --err
pm2 restart turbotrades
```
### MongoDB Not Running:
```bash
ssh root@178.63.127.19
systemctl start mongod
systemctl status mongod
```
### Need to Restart Everything:
```bash
ssh root@178.63.127.19
pm2 restart all
systemctl restart mongod
systemctl restart nginx
```
### Port 3000 Already in Use:
```bash
ssh root@178.63.127.19
lsof -i :3000
pm2 delete turbotrades
pm2 start ecosystem.config.js --env production
```
---
## 📝 Important URLs
- **Gitea Repo:** https://git.turbotrades.dev/iDefineHD/TurboTrades
- **CI/CD Actions:** Check your Gitea repository's Actions tab
- **Repository Secrets:** https://git.turbotrades.dev/iDefineHD/TurboTrades/settings
- **Your Server:** http://178.63.127.19
- **API Health:** http://178.63.127.19:3000/api/health
- **Admin Panel:** http://178.63.127.19/admin
---
## 🎉 You're Done!
Visit: **http://178.63.127.19**
Your admin panel is fully functional with:
- ✅ User Management
- ✅ Promotion Analytics
- ✅ Trading & Market Settings
- ✅ Announcements
- ✅ Maintenance Mode
---
## 📞 Need Help?
1. Check server logs: `ssh root@178.63.127.19 "pm2 logs"`
2. Check Gitea Actions in your repository
3. Review full guide: `DEPLOYMENT_GUIDE.md`
**Happy deploying! 🚀**