From ab4e7934f84b253c7773fd1ad7916ecfc5d473ea Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 6 Oct 2025 21:42:40 +0000 Subject: [PATCH] docs: Add simple deployment instructions for production server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step-by-step guide to deploy on 10.0.0.240: 1. SSH to root@10.0.0.240 2. Download and run deployment script 3. Edit environment variables 4. Verify deployment Includes troubleshooting and management commands. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- DEPLOY_NOW.md | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 DEPLOY_NOW.md diff --git a/DEPLOY_NOW.md b/DEPLOY_NOW.md new file mode 100644 index 0000000..d8b9d98 --- /dev/null +++ b/DEPLOY_NOW.md @@ -0,0 +1,170 @@ +# 🚀 Deploy ParentFlow to Production - Step by Step + +## Quick Deploy Instructions + +### Step 1: Connect to Production Server + +Open your terminal and connect via SSH: +```bash +ssh root@10.0.0.240 +# Password: a3pq5t50yA@# +``` + +### Step 2: Download and Run Deployment Script + +Once connected to the server, run these commands: + +```bash +# Download the deployment script +wget https://git.noru1.ro/andrei/maternal-app/raw/branch/main/deploy-to-production.sh + +# Make it executable +chmod +x deploy-to-production.sh + +# Run the deployment +./deploy-to-production.sh +``` + +### Step 3: Edit Environment Variables (First Time Only) + +The script will pause and ask you to edit `.env.production`. +You need to update these critical values: + +```bash +# Edit the file +nano /root/maternal-app/.env.production +``` + +Key values to update: +- `JWT_SECRET` - Generate with: `openssl rand -base64 64` +- `JWT_REFRESH_SECRET` - Generate with: `openssl rand -base64 64` +- `OPENAI_API_KEY` - Your OpenAI API key for AI features +- Redis, MongoDB, MinIO passwords (keep defaults or change) + +Press `Ctrl+X`, then `Y`, then `Enter` to save and exit. + +Then press `Enter` in the deployment script to continue. + +### Step 4: Verify Deployment + +After the script completes, verify everything is running: + +```bash +# Check PM2 processes +pm2 status + +# Check Docker containers +docker ps + +# Check if services are accessible +curl http://localhost:3020/api/health +curl http://localhost:3030 +``` + +## What the Script Does + +1. ✅ Clones the repository from Gitea +2. ✅ Installs Node.js 18, PM2, Docker, Docker Compose +3. ✅ Installs all npm dependencies +4. ✅ Builds backend and frontend +5. ✅ Starts Docker containers (Redis, MongoDB, MinIO) +6. ✅ Runs database migrations on 10.0.0.207 +7. ✅ Starts PM2 processes for backend (3020) and frontend (3030) +8. ✅ Sets up PM2 to restart on system reboot + +## After Deployment + +### Test the Application + +From your local machine: +1. Backend Health: http://10.0.0.240:3020/api/health +2. Frontend: http://10.0.0.240:3030 + +### Production URLs (Already configured in Nginx) + +- API: https://api.parentflowapp.com +- Web: https://web.parentflowapp.com + +### Management Commands + +On the production server: + +```bash +# View logs +pm2 logs + +# Restart services +pm2 restart all + +# Stop services +pm2 stop all + +# View real-time metrics +pm2 monit + +# Docker logs +docker logs parentflow-redis-prod +docker logs parentflow-mongodb-prod +``` + +## Troubleshooting + +### If backend doesn't start: +```bash +pm2 logs parentflow-backend-prod --err +cd /root/maternal-app/maternal-app/maternal-app-backend +npm run build +pm2 restart parentflow-backend-prod +``` + +### If frontend doesn't start: +```bash +pm2 logs parentflow-frontend-prod --err +cd /root/maternal-app/maternal-web +npm run build +pm2 restart parentflow-frontend-prod +``` + +### If database connection fails: +```bash +# Test connection +PGPASSWORD=a3ppq psql -h 10.0.0.207 -p 5432 -U postgres -d parentflow -c "SELECT version();" + +# Check migrations +cd /root/maternal-app/maternal-app/maternal-app-backend +./scripts/check-migrations.sh +``` + +### To update after changes: +```bash +cd /root/maternal-app +git pull origin main +cd maternal-app/maternal-app-backend +npm install +npm run build +cd ../../maternal-web +npm install +npm run build +pm2 restart all +``` + +## Success Indicators + +You'll know deployment is successful when: +- ✅ `pm2 status` shows both processes as "online" +- ✅ `docker ps` shows 3 containers running +- ✅ Backend responds at http://10.0.0.240:3020/api/health +- ✅ Frontend loads at http://10.0.0.240:3030 +- ✅ You can register/login at https://web.parentflowapp.com + +## Support + +If you encounter issues: +1. Check logs: `pm2 logs` +2. Check Docker: `docker ps` and `docker logs [container-name]` +3. Verify PostgreSQL connection to 10.0.0.207 +4. Ensure ports 3020 and 3030 are not blocked + +--- + +**Ready to deploy! Just SSH to the server and run the 3 commands in Step 2.** \ No newline at end of file