4.5 KiB
4.5 KiB
🚀 LuckyChit Deployment Guide
Complete production deployment guide.
📍 Production Setup
Server IP: 192.168.8.148
Domain: chitfund.deepteklabs.com
User: luckychit
Project: /home/luckychit/apps/chitfund
Branch: prodnew
🏗️ Architecture
Internet
↓
Cloudflare (SSL, CDN)
↓
Nginx Proxy (LXC 1)
↓
Application Server (LXC 2: 192.168.8.148)
├── PM2: luckychit-api (Port 3000)
├── PM2: luckychit-frontend (Port 8080)
└── PostgreSQL (Port 5432)
⚡ Quick Deploy
ssh luckychit@192.168.8.148
cd /home/luckychit/apps/chitfund
./scripts/deploy.sh
Deploy Options:
./scripts/deploy.sh # Deploy both backend + frontend
./scripts/deploy.sh backend # Backend only
./scripts/deploy.sh frontend # Frontend only
🔧 Manual Deployment
Backend
cd /home/luckychit/apps/chitfund
git pull origin prodnew
cd backend
npm install
pm2 restart luckychit-api
pm2 logs luckychit-api --lines 20
Frontend
cd /home/luckychit/apps/chitfund
git pull origin prodnew
cd luckychit
flutter pub get
flutter build web --release --pwa-strategy=none
pm2 restart luckychit-frontend
pm2 logs luckychit-frontend --lines 20
📊 PM2 Commands
pm2 status # Show all processes
pm2 logs # Live logs
pm2 logs luckychit-api # Backend logs
pm2 logs luckychit-frontend # Frontend logs
pm2 restart all # Restart everything
pm2 monit # Real-time monitoring
🗑️ Clear Caches (After Deployment)
1. Server Cache
pm2 restart all
2. Nginx Proxy Cache (if using separate LXC)
ssh root@<nginx-lxc-ip>
sudo rm -rf /var/cache/nginx/*
sudo systemctl reload nginx
3. Cloudflare Cache
- Login to Cloudflare dashboard
- Caching → Purge Everything
4. Browser Cache
Hard Refresh: Ctrl + Shift + R (Windows) or Cmd + Shift + R (Mac)
Or test in Incognito: Ctrl + Shift + N
🔥 Emergency: Complete Cache Clear
cd /home/luckychit/apps/chitfund
./scripts/deploy.sh --force
This will:
- Clean all build caches
- Rebuild from scratch
- Restart all services
- Clear nginx cache (if configured)
🗄️ Database Backup
Manual Backup
./scripts/backup-db.sh
Automated Daily Backup
# Add to crontab
crontab -e
# Add: 0 2 * * * /home/luckychit/apps/chitfund/scripts/backup-db.sh
Restore from Backup
./scripts/restore-db.sh
🔍 Initial Server Setup (One-Time)
1. Install Dependencies
# Node.js, Flutter, PM2, PostgreSQL
# See PM2_PRODUCTION_GUIDE.md for details
2. Setup PM2
cd /home/luckychit/apps/chitfund/backend
pm2 start src/server.js --name luckychit-api
cd ../luckychit
pm2 serve build/web 8080 --name luckychit-frontend --spa
pm2 save
pm2 startup systemd -u luckychit --hp /home/luckychit
3. Configure Auto-start
pm2 startup
# Run the command it outputs
pm2 save
🔐 Security Checklist
- Firewall configured (ports 3000, 8080)
- Strong database password
- JWT secret set (32+ characters)
- SSL/TLS enabled (via Cloudflare)
- Database backups automated
- PM2 auto-start configured
📋 Pre-Deployment Checklist
- Changes tested locally
- Committed to git
- Pushed to
prodnewbranch - Database migrations ready (if any)
- Backup recent (< 24 hours)
📋 Post-Deployment Checklist
pm2 statusshows all online- No errors in
pm2 logs - Backend health check works:
curl http://localhost:3000/health - Frontend loads:
curl http://localhost:8080 - Domain works: https://chitfund.deepteklabs.com
- Login works
- Clear browser cache tested
🆘 Troubleshooting
See TROUBLESHOOTING.md for common issues and fixes.
Quick diagnostics:
./scripts/diagnose.sh
📞 Emergency Contacts
If everything is broken:
./scripts/diagnose.sh # See what's wrong
./scripts/fix-502.sh # Fix 502 errors
pm2 restart all # Restart everything
📚 Additional Resources
- PM2 Production Guide: PM2_PRODUCTION_GUIDE.md
- Quick Reference: QUICK_REFERENCE.md
- Backend API Docs: backend/API_DOCUMENTATION.md
Last Updated: November 2025