|
| 1 | +# Deployment Guide for Render |
| 2 | + |
| 3 | +This guide will help you deploy the SecureComm Chat application on Render. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- A GitHub account |
| 8 | +- A Render account (sign up at https://render.com) |
| 9 | +- Your code pushed to a GitHub repository |
| 10 | + |
| 11 | +## Deployment Steps |
| 12 | + |
| 13 | +### Option 1: Using render.yaml (Recommended) |
| 14 | + |
| 15 | +1. **Push your code to GitHub** |
| 16 | + ```bash |
| 17 | + git init |
| 18 | + git add . |
| 19 | + git commit -m "Initial commit" |
| 20 | + git remote add origin <your-github-repo-url> |
| 21 | + git push -u origin main |
| 22 | + ``` |
| 23 | + |
| 24 | +2. **Connect to Render** |
| 25 | + - Go to https://dashboard.render.com |
| 26 | + - Click "New +" |
| 27 | + - Select "Blueprint" |
| 28 | + - Connect your GitHub repository |
| 29 | + - Render will automatically detect the `render.yaml` file |
| 30 | + |
| 31 | +3. **Configure Environment Variables** |
| 32 | + |
| 33 | + For the **backend service**: |
| 34 | + - `FRONTEND_URL`: Set this to your frontend URL after deployment (e.g., `https://securecomm-frontend.onrender.com`) |
| 35 | + |
| 36 | + For the **frontend service**: |
| 37 | + - `VITE_SERVER_URL`: Set this to your backend URL (e.g., `https://securecomm-backend.onrender.com`) |
| 38 | + - `VITE_SUPABASE_ANON_KEY`: Your Supabase anonymous key |
| 39 | + |
| 40 | +4. **Deploy** |
| 41 | + - Click "Apply" to deploy both services |
| 42 | + - Wait for the deployment to complete (this may take a few minutes) |
| 43 | + |
| 44 | +5. **Update CORS Settings** |
| 45 | + - After frontend deploys, note the URL |
| 46 | + - Update the backend's `FRONTEND_URL` environment variable |
| 47 | + - The backend will automatically restart |
| 48 | + |
| 49 | +### Option 2: Manual Deployment |
| 50 | + |
| 51 | +#### Deploy Backend |
| 52 | + |
| 53 | +1. Go to https://dashboard.render.com |
| 54 | +2. Click "New +" → "Web Service" |
| 55 | +3. Connect your GitHub repository |
| 56 | +4. Configure: |
| 57 | + - **Name**: securecomm-backend |
| 58 | + - **Environment**: Node |
| 59 | + - **Build Command**: `npm install` |
| 60 | + - **Start Command**: `npm run start` |
| 61 | + - **Plan**: Free |
| 62 | +5. Add environment variables: |
| 63 | + - `NODE_ENV`: production |
| 64 | + - `PORT`: 3001 |
| 65 | + - `FRONTEND_URL`: (add after frontend deployment) |
| 66 | +6. Click "Create Web Service" |
| 67 | + |
| 68 | +#### Deploy Frontend |
| 69 | + |
| 70 | +1. Click "New +" → "Static Site" |
| 71 | +2. Connect your GitHub repository |
| 72 | +3. Configure: |
| 73 | + - **Name**: securecomm-frontend |
| 74 | + - **Build Command**: `npm install && npm run build` |
| 75 | + - **Publish Directory**: `dist` |
| 76 | +4. Add environment variables: |
| 77 | + - `VITE_SERVER_URL`: Your backend URL from step above |
| 78 | + - `VITE_SUPABASE_URL`: https://0ec90b57d6e95fcbda19832f.supabase.co |
| 79 | + - `VITE_SUPABASE_ANON_KEY`: Your Supabase key |
| 80 | +5. Click "Create Static Site" |
| 81 | + |
| 82 | +#### Final Configuration |
| 83 | + |
| 84 | +1. Copy your frontend URL |
| 85 | +2. Go to backend service settings |
| 86 | +3. Add `FRONTEND_URL` environment variable with the frontend URL |
| 87 | +4. Backend will automatically redeploy |
| 88 | + |
| 89 | +## Important Notes |
| 90 | + |
| 91 | +### Free Tier Limitations |
| 92 | + |
| 93 | +- Free services spin down after 15 minutes of inactivity |
| 94 | +- First request after spin-down may take 30-60 seconds |
| 95 | +- WebSocket connections may be interrupted during spin-down |
| 96 | +- Consider upgrading to paid plan for production use |
| 97 | + |
| 98 | +### Environment Variables |
| 99 | + |
| 100 | +Make sure to set these environment variables correctly: |
| 101 | + |
| 102 | +**Backend:** |
| 103 | +- `FRONTEND_URL`: Your deployed frontend URL |
| 104 | +- `PORT`: 3001 (or use Render's default) |
| 105 | +- `NODE_ENV`: production |
| 106 | + |
| 107 | +**Frontend:** |
| 108 | +- `VITE_SERVER_URL`: Your deployed backend URL |
| 109 | +- `VITE_SUPABASE_URL`: Your Supabase project URL |
| 110 | +- `VITE_SUPABASE_ANON_KEY`: Your Supabase anonymous key |
| 111 | + |
| 112 | +### Troubleshooting |
| 113 | + |
| 114 | +**Connection Issues:** |
| 115 | +- Verify environment variables are set correctly |
| 116 | +- Check that CORS is properly configured |
| 117 | +- Ensure backend URL in frontend matches actual backend URL |
| 118 | +- Check browser console for detailed error messages |
| 119 | + |
| 120 | +**WebSocket Issues:** |
| 121 | +- Render's free tier may have WebSocket limitations |
| 122 | +- Consider using polling as fallback (already configured) |
| 123 | +- Check that both services are awake and running |
| 124 | + |
| 125 | +**Build Failures:** |
| 126 | +- Check build logs in Render dashboard |
| 127 | +- Verify all dependencies are in package.json |
| 128 | +- Ensure Node version compatibility |
| 129 | + |
| 130 | +### Monitoring |
| 131 | + |
| 132 | +- Check service logs in Render dashboard |
| 133 | +- Monitor health check endpoint: `<backend-url>/health` |
| 134 | +- Use browser console for frontend debugging |
| 135 | + |
| 136 | +## Support |
| 137 | + |
| 138 | +For issues specific to Render deployment, check: |
| 139 | +- Render documentation: https://render.com/docs |
| 140 | +- Render community: https://community.render.com |
0 commit comments