-
.github/workflows/ci.yml: Continuous Integration- Runs on push/PR to main/master
- Builds and tests the application
-
.github/workflows/deploy.yml: Production Deployment- Runs on push to main/master
- Builds frontend
- Deploys to server via SSH
- Uses PM2 for process management
Dockerfile: Multi-stage Docker build for backenddocker-compose.yml: Docker Compose configuration (optional)infrastructure/nginx/: Nginx configurationsnginx.conf: Main Nginx configdefault.conf: Docker Compose configliveweb.conf: Production domain config
infrastructure/scripts/deploy.sh: Main deployment scriptinfrastructure/scripts/verify-deployment.sh: Verification scriptinfrastructure/scripts/setup-nginx.sh: Nginx setup script
- Backend serves frontend in production mode
- CORS configured for multiple origins
- API_BASE_URL configurable via environment variable
┌─────────────────────────────────────┐
│ GitHub Actions (CI/CD) │
│ - Build frontend │
│ - Copy files to server │
│ - Run deployment script │
└──────────────┬──────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Production Server │
│ /opt/liveweb/ │
│ ├── server/ (Backend) │
│ ├── frontend/dist/ (Frontend) │
│ ├── infrastructure/ (Scripts) │
│ └── .env (Config) │
└──────────────┬──────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ PM2 Process Manager │
│ - Manages Node.js process │
│ - Auto-restart on failure │
│ - Logs management │
└──────────────┬──────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Application │
│ - Backend: Port 3000 │
│ - Frontend: Served by backend │
│ - Or via Nginx: Port 80/443 │
└─────────────────────────────────────┘
See .github/SECRETS_SETUP.md for detailed instructions.
Minimum required secrets:
SERVER_IPSERVER_USER(or use defaultroot)SERVER_SSH_KEYORSERVER_PASSWORDGEMINI_API_KEY
On your server, ensure:
- Node.js 22+ is installed
- PM2 is available (will be installed by script)
- Port 3000 is available (or change in
.env) - Firewall allows SSH (port 22) and application port
- Push code to
mainormasterbranch - GitHub Actions will automatically:
- Build frontend
- Copy files to server
- Run deployment script
- Start application with PM2
# SSH into server
ssh user@your-server-ip
# Check PM2 status
pm2 status liveweb
# Check health
curl http://localhost:3000/health
# View logs
pm2 logs livewebApplication accessible at:
http://YOUR_SERVER_IP:3000
-
Point DNS:
A record: liveweb.yourdomain.com → YOUR_SERVER_IP -
Setup Nginx:
sudo ./infrastructure/scripts/setup-nginx.sh yourdomain.com
-
Get SSL:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
-
Application accessible at:
https://yourdomain.com
If port 3000 is already in use by another service:
-
Change backend port:
# In .env file PORT=3001
-
Update frontend build:
# Set before building export VITE_API_BASE_URL=http://yourdomain.com:3001 cd frontend && npm run build
-
Update Nginx (if using):
upstream liveweb_backend { server 127.0.0.1:3001; # New port }
# Status
pm2 status
# Logs
pm2 logs liveweb
# Restart
pm2 restart liveweb
# Stop
pm2 stop liveweb
# Monitor
pm2 monit- PM2 logs:
pm2 logs liveweb - Application logs:
/opt/liveweb/logs/app.log - Error logs:
/opt/liveweb/logs/error.log - Deploy logs:
/opt/liveweb/logs/deploy.log
- SSH keys configured (not passwords)
- Firewall configured (UFW/iptables)
- SSL certificate installed (for custom domain)
- Environment variables secured
- PM2 startup script configured
- Regular backups configured
- Fail2ban configured (optional)
# Find process
sudo lsof -i :3000
# Kill process (if safe)
sudo kill -9 <PID>
# Or change port in .env# Rebuild frontend
cd /opt/liveweb/frontend
npm run build
# Restart backend
pm2 restart liveweb- Check
API_BASE_URLin.env - Verify frontend was built with correct
VITE_API_BASE_URL - Check CORS configuration in
server/middleware/cors.js
For deployment issues:
- Check PM2 logs:
pm2 logs liveweb - Check deployment logs:
/opt/liveweb/logs/deploy.log - Check Nginx logs:
/var/log/nginx/liveweb-error.log - Review GitHub Actions logs in repository
Next Steps:
- Configure GitHub Secrets (see
.github/SECRETS_SETUP.md) - Push to
mainbranch - Monitor deployment in GitHub Actions
- Verify application is running
- Configure custom domain (optional)