- Added Docker support (Dockerfiles, docker-compose.yml) - Fixed authentication and authorization (token storage, CORS, permissions) - Fixed API response transformations for all modules - Added production deployment scripts and guides - Fixed frontend permission checks and module access - Added database seeding script for production - Complete documentation for deployment and configuration Co-authored-by: Cursor <cursoragent@cursor.com>
317 lines
6.5 KiB
Markdown
317 lines
6.5 KiB
Markdown
# 🎉 Z.CRM Deployment Successful!
|
|
|
|
## ✅ Deployment Status: COMPLETE
|
|
|
|
Your Z.CRM application has been successfully deployed to your server!
|
|
|
|
---
|
|
|
|
## 🌐 Server Information
|
|
|
|
| Item | Details |
|
|
|------|---------|
|
|
| **Server IP** | 37.60.249.71 |
|
|
| **Domain** | zerp.atmata-group.com |
|
|
| **SSH User** | root |
|
|
| **Application Directory** | `/opt/zerp` |
|
|
|
|
---
|
|
|
|
## 🚀 Services Running
|
|
|
|
| Service | Status | Port | URL |
|
|
|---------|--------|------|-----|
|
|
| **Frontend** | ✅ Running | 3000 | http://37.60.249.71:3000 |
|
|
| **Backend API** | ✅ Running | 5001 | http://37.60.249.71:5001 |
|
|
| **PostgreSQL Database** | ✅ Running | 5432 | localhost:5432 |
|
|
|
|
---
|
|
|
|
## 📋 CRITICAL: Configure Nginx Proxy Manager
|
|
|
|
**You MUST configure Nginx Proxy Manager to make your application accessible via the domain.**
|
|
|
|
### Configuration Steps:
|
|
|
|
1. **Access your Nginx Proxy Manager** (usually at http://your-npm-ip:81)
|
|
|
|
2. **Add a new Proxy Host** with these settings:
|
|
|
|
#### Details Tab:
|
|
```
|
|
Domain Names: zerp.atmata-group.com
|
|
Scheme: http
|
|
Forward Hostname/IP: localhost (or 37.60.249.71)
|
|
Forward Port: 3000
|
|
✓ Cache Assets
|
|
✓ Block Common Exploits
|
|
✓ Websockets Support
|
|
```
|
|
|
|
#### SSL Tab:
|
|
```
|
|
✓ Request a new SSL Certificate (Let's Encrypt)
|
|
✓ Force SSL
|
|
✓ HTTP/2 Support
|
|
✓ HSTS Enabled
|
|
Email: your-email@example.com
|
|
✓ I Agree to the Let's Encrypt Terms of Service
|
|
```
|
|
|
|
#### Advanced Tab (Optional - for API routing):
|
|
```nginx
|
|
# If you want to access API directly via subdomain or path
|
|
location /api {
|
|
proxy_pass http://localhost:5001;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $host;
|
|
proxy_cache_bypass $http_upgrade;
|
|
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;
|
|
}
|
|
```
|
|
|
|
3. **Save** and wait for SSL certificate to be issued
|
|
|
|
4. **Access your application** at: **https://zerp.atmata-group.com**
|
|
|
|
---
|
|
|
|
## 🔐 Security: Update Environment Variables
|
|
|
|
**IMPORTANT:** The deployment created default environment variables. You MUST update them with secure values!
|
|
|
|
### SSH to your server:
|
|
```bash
|
|
ssh root@37.60.249.71
|
|
```
|
|
|
|
### Edit the environment file:
|
|
```bash
|
|
nano /opt/zerp/.env
|
|
```
|
|
|
|
### Update these values:
|
|
```bash
|
|
# Change this to a strong password
|
|
POSTGRES_PASSWORD=YourVerySecurePassword123!
|
|
|
|
# This was randomly generated but you can change it
|
|
JWT_SECRET=your-super-secure-jwt-secret-here
|
|
|
|
# Domain is already set
|
|
DOMAIN=zerp.atmata-group.com
|
|
```
|
|
|
|
### After updating, restart services:
|
|
```bash
|
|
cd /opt/zerp
|
|
docker-compose restart
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 Monitoring & Management
|
|
|
|
### View Service Status:
|
|
```bash
|
|
cd /opt/zerp
|
|
docker-compose ps
|
|
```
|
|
|
|
### View Logs:
|
|
```bash
|
|
# All services
|
|
docker-compose logs -f
|
|
|
|
# Specific service
|
|
docker-compose logs -f frontend
|
|
docker-compose logs -f backend
|
|
docker-compose logs -f postgres
|
|
```
|
|
|
|
### Restart Services:
|
|
```bash
|
|
cd /opt/zerp
|
|
docker-compose restart
|
|
```
|
|
|
|
### Stop Services:
|
|
```bash
|
|
docker-compose down
|
|
```
|
|
|
|
### Update Application (after making changes):
|
|
```bash
|
|
# From your local machine
|
|
cd /Users/talalsharabi/z_crm
|
|
./quick-deploy.sh
|
|
|
|
# Or manually
|
|
rsync -avz --exclude 'node_modules' --exclude '.git' \
|
|
./ root@37.60.249.71:/opt/zerp/
|
|
|
|
# Then on server
|
|
ssh root@37.60.249.71
|
|
cd /opt/zerp
|
|
docker-compose down
|
|
docker-compose up -d --build
|
|
```
|
|
|
|
---
|
|
|
|
## 🗄️ Database Management
|
|
|
|
### Access Database:
|
|
```bash
|
|
docker-compose exec postgres psql -U postgres mind14_crm
|
|
```
|
|
|
|
### Backup Database:
|
|
```bash
|
|
docker-compose exec postgres pg_dump -U postgres mind14_crm > backup_$(date +%Y%m%d).sql
|
|
```
|
|
|
|
### Restore Database:
|
|
```bash
|
|
docker-compose exec -T postgres psql -U postgres mind14_crm < backup_20240101.sql
|
|
```
|
|
|
|
### Run Migrations:
|
|
```bash
|
|
docker-compose exec backend npx prisma migrate deploy
|
|
```
|
|
|
|
---
|
|
|
|
## 🔥 Firewall Configuration (Recommended)
|
|
|
|
Secure your server by only allowing necessary ports:
|
|
|
|
```bash
|
|
# SSH to server
|
|
ssh root@37.60.249.71
|
|
|
|
# Configure firewall
|
|
ufw allow 22/tcp # SSH
|
|
ufw allow 80/tcp # HTTP
|
|
ufw allow 443/tcp # HTTPS
|
|
ufw enable
|
|
|
|
# Verify
|
|
ufw status
|
|
```
|
|
|
|
---
|
|
|
|
## ⚠️ Troubleshooting
|
|
|
|
### Frontend Can't Connect to Backend
|
|
1. Check backend logs: `docker-compose logs backend`
|
|
2. Verify backend is running: `docker-compose ps`
|
|
3. Check CORS settings in backend
|
|
|
|
### Database Connection Issues
|
|
1. Check postgres logs: `docker-compose logs postgres`
|
|
2. Verify DATABASE_URL in backend container
|
|
3. Ensure postgres is healthy
|
|
|
|
### Port Already in Use
|
|
```bash
|
|
# Find process using port
|
|
netstat -tulpn | grep :3000
|
|
|
|
# Kill process
|
|
kill -9 <PID>
|
|
```
|
|
|
|
### Reset Everything
|
|
```bash
|
|
cd /opt/zerp
|
|
docker-compose down -v # WARNING: This deletes all data!
|
|
docker-compose up -d --build
|
|
```
|
|
|
|
---
|
|
|
|
## 📞 Default Login Credentials
|
|
|
|
After deployment, you need to seed the database with initial user:
|
|
|
|
```bash
|
|
# SSH to server
|
|
ssh root@37.60.249.71
|
|
|
|
# Run seed command
|
|
cd /opt/zerp
|
|
docker-compose exec backend npx prisma db seed
|
|
```
|
|
|
|
**Default admin credentials will be shown in the seed output.**
|
|
|
|
---
|
|
|
|
## ✨ Next Steps
|
|
|
|
1. ✅ Configure Nginx Proxy Manager (see above)
|
|
2. ✅ Update `.env` file with secure passwords
|
|
3. ✅ Configure firewall
|
|
4. ✅ Seed database with initial data
|
|
5. ✅ Test application at https://zerp.atmata-group.com
|
|
6. ✅ Set up regular database backups
|
|
7. ✅ Configure monitoring/alerts (optional)
|
|
|
|
---
|
|
|
|
## 🎯 Port Summary for Nginx Proxy Manager
|
|
|
|
**Main Configuration:**
|
|
- **Point domain `zerp.atmata-group.com` to port `3000`**
|
|
|
|
That's it! The frontend on port 3000 will automatically proxy API requests to the backend on port 5001.
|
|
|
|
---
|
|
|
|
## 📁 Project Structure on Server
|
|
|
|
```
|
|
/opt/zerp/
|
|
├── backend/ # Backend API
|
|
├── frontend/ # Frontend Next.js app
|
|
├── docker-compose.yml # Docker services configuration
|
|
├── .env # Environment variables (UPDATE THIS!)
|
|
└── ... other files
|
|
```
|
|
|
|
---
|
|
|
|
## 🆘 Need Help?
|
|
|
|
1. Check logs: `docker-compose logs -f`
|
|
2. Check service status: `docker-compose ps`
|
|
3. Restart services: `docker-compose restart`
|
|
4. Review this documentation
|
|
5. Check the main DEPLOYMENT_GUIDE.md for detailed instructions
|
|
|
|
---
|
|
|
|
## 🎉 Congratulations!
|
|
|
|
Your Z.CRM system is now deployed and ready to use!
|
|
|
|
**Remember to:**
|
|
- ✅ Configure Nginx Proxy Manager
|
|
- ✅ Update environment variables
|
|
- ✅ Secure your server with firewall rules
|
|
- ✅ Test the application thoroughly
|
|
- ✅ Set up regular backups
|
|
|
|
---
|
|
|
|
**Deployment Date:** February 9, 2026
|
|
**Server:** 37.60.249.71
|
|
**Domain:** zerp.atmata-group.com
|