# Production Deployment Guide ## Prerequisites - Docker and Docker Compose - Domain name (optional) - SSL certificate (for HTTPS) ## Environment Setup 1. **Create environment file:** ```bash cp .env.example .env ``` 2. **Configure production variables:** ```bash # Database POSTGRES_PASSWORD=your_secure_database_password_here JWT_SECRET=your_jwt_secret_here # API REACT_APP_API_URL=http://your-domain.com:3001 # Security CORS_ORIGIN=https://your-domain.com ``` ## Deployment ### Option 1: Docker Compose (Recommended) ```bash # Production deployment docker-compose -f docker-compose.prod.yml up -d # Check status docker-compose -f docker-compose.prod.yml ps # View logs docker-compose -f docker-compose.prod.yml logs -f ``` ### Option 2: Individual Services ```bash # Build production images docker build -t merchantsofhope-backend:prod ./backend docker build -t merchantsofhope-frontend:prod ./frontend # Run database docker run -d --name db \ -e POSTGRES_PASSWORD=your_password \ -v postgres_data:/var/lib/postgresql/data \ postgres:15-alpine # Run backend docker run -d --name backend \ -e DATABASE_URL=postgresql://user:pass@db:5432/db \ -e JWT_SECRET=your_secret \ -p 3001:3001 \ merchantsofhope-backend:prod # Run frontend docker run -d --name frontend \ -e REACT_APP_API_URL=http://backend:3001 \ -p 80:80 \ merchantsofhope-frontend:prod ``` ## Health Checks - Backend: `http://localhost:3001/api/health` - Frontend: `http://localhost:80` - Database: Check container logs ## Security Considerations 1. **Change default passwords** 2. **Use strong JWT secrets** 3. **Configure CORS properly** 4. **Set up SSL/TLS** 5. **Regular security updates** 6. **Monitor logs** ## Monitoring ```bash # View application logs docker-compose -f docker-compose.prod.yml logs -f # Check resource usage docker stats # Database backup docker exec merchantsofhope-supplyanddemandportal-database pg_dump -U user db > backup.sql ``` ## Troubleshooting 1. **Database connection issues:** - Check POSTGRES_PASSWORD - Verify network connectivity - Check database logs 2. **Frontend not loading:** - Check REACT_APP_API_URL - Verify backend is running - Check nginx logs 3. **Authentication issues:** - Verify JWT_SECRET - Check token expiration - Review auth logs