# Production Server Deployment Instructions ## Quick Deploy on Server 10.0.0.240 Since the repository has already been cloned, run these commands: ```bash # Navigate to the project directory cd /root/maternal-app # Switch to the main branch (where all the code is) git checkout main git pull origin main # Make deployment script executable and run it chmod +x deploy-to-production.sh ./deploy-to-production.sh ``` ## What the Deployment Script Does 1. **Installs System Dependencies** - Node.js 20.x - PM2 process manager - Docker and Docker Compose - PostgreSQL client tools 2. **Sets Up Database** - Connects to PostgreSQL at 10.0.0.207 - Creates parentflow database if needed - Runs all migrations in sequence 3. **Starts Services** - Redis, MongoDB, MinIO via Docker Compose - Backend API on port 3020 via PM2 - Frontend on port 3005 via PM2 4. **Configures PM2** - Sets up auto-restart on system reboot - Saves PM2 configuration ## Manual Commands if Needed ### Check out the main branch: ```bash git checkout main git pull origin main ``` ### Start all services: ```bash ./start-production.sh ``` ### Stop all services: ```bash ./stop-production.sh ``` ### Check PM2 status: ```bash pm2 status pm2 logs ``` ### Check Docker services: ```bash docker-compose -f docker-compose.production.yml ps docker-compose -f docker-compose.production.yml logs ``` ## Important Notes - **Database**: PostgreSQL is on dedicated server 10.0.0.207 (not in Docker) - **Default branch issue**: The repository default branch is 'master' but all code is on 'main' - **Always use main branch**: Make sure to checkout main branch after cloning