- Install Vercel CLI:
npm i -g vercel- Build the client:
cd client
npm run build- Deploy:
vercel --prod- Configure:
- Set build command:
npm run build - Set output directory:
dist - Set install command:
npm install
Deploy backend separately on Render, Railway, or Fly.io (see below).
- Build:
cd client
npm run build- Deploy via Netlify CLI:
npm install -g netlify-cli
netlify deploy --prod- Configure:
- Build command:
npm run build - Publish directory:
dist
- Connect your GitHub repo
- Set build command:
cd client && npm install && npm run build - Set publish directory:
client/dist
- Connect your GitHub repo
- Set build command:
cd server && npm install - Set start command:
cd server && npm start - Add environment variables from
.env.example
- Install Railway CLI:
npm i -g @railway/cli- Login:
railway login- Deploy Backend:
cd server
railway up- Deploy Frontend:
cd client
railway up- Set Environment Variables in Railway dashboard
FROM node:18-alpine
WORKDIR /app
COPY server/package*.json ./
RUN npm install --production
COPY server/ ./
EXPOSE 5000
CMD ["node", "src/index.js"]FROM node:18-alpine as build
WORKDIR /app
COPY client/package*.json ./
RUN npm install
COPY client/ ./
RUN npm run build
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]version: '3.8'
services:
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
ports:
- "80:80"
depends_on:
- backend
backend:
build:
context: .
dockerfile: Dockerfile.backend
ports:
- "5000:5000"
environment:
- PORT=5000
- MONGODB_URI=${MONGODB_URI}
depends_on:
- mongodb
mongodb:
image: mongo:6
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
volumes:
mongodb_data:Deploy:
docker-compose up -d- Build:
cd client && npm run build- Upload to S3:
aws s3 sync dist/ s3://your-bucket-name --delete- Configure CloudFront for CDN
- Launch EC2 instance
- Install Node.js:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs- Clone and setup:
git clone <your-repo>
cd collapsing-ide-pro/server
npm install- Use PM2 for process management:
npm install -g pm2
pm2 start src/index.js --name collapsing-ide-backend
pm2 startup
pm2 saveVITE_API_URL=https://your-backend-url.com
VITE_SOCKET_URL=https://your-backend-url.comPORT=5000
NODE_ENV=production
CLIENT_URL=https://your-frontend-url.com
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/collapsing-ide
JWT_SECRET=super_secure_random_string_here// server/src/index.js
import compression from 'compression';
app.use(compression());app.use(express.static('public', {
maxAge: '1y',
etag: false
}));Upload Monaco Editor files to CDN and reference in index.html.
# nginx.conf
gzip on;
gzip_types text/plain text/css application/json application/javascript;npm install newrelic
# or
npm install @sentry/nodeAlready included at /api/health
- Enable HTTPS (use Let's Encrypt)
- Set secure headers (helmet.js already configured)
- Enable CORS with specific origins
- Rate limit API endpoints (already configured)
- Use environment variables for secrets
- Enable MongoDB authentication
- Implement JWT authentication for API
- Add input validation
- Enable CSP headers
- Regular dependency updates
Use load balancer (AWS ALB, Nginx) with multiple backend instances:
upstream backend {
server backend1:5000;
server backend2:5000;
server backend3:5000;
}
server {
location /api {
proxy_pass http://backend;
}
}Use MongoDB Atlas with replica sets and sharding.
name: Deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install dependencies
run: |
npm install
cd client && npm install
cd ../server && npm install
- name: Build frontend
run: cd client && npm run build
- name: Deploy to Vercel
run: vercel --prod --token=${{ secrets.VERCEL_TOKEN }}-
CORS Errors
- Check CLIENT_URL in backend .env
- Verify CORS configuration in server/src/index.js
-
Socket.IO Connection Failed
- Ensure WebSocket support on hosting platform
- Check firewall rules
-
MongoDB Connection Timeout
- Whitelist IP address in MongoDB Atlas
- Verify connection string
-
Build Failures
- Clear node_modules and reinstall
- Check Node.js version (18+)
- Frontend: Vercel/Netlify (Free)
- Backend: Render/Railway (Free tier available)
- Database: MongoDB Atlas (512MB free)
Total: $0/month for low traffic
- Frontend: Vercel Pro ($20/month)
- Backend: AWS EC2 t3.small ($15/month)
- Database: MongoDB Atlas M10 ($57/month)
- CDN: CloudFront ($5-10/month)
Total: ~$100/month
For deployment issues:
- Check the logs
- Open an issue on GitHub
- Contact support
Happy deploying! 💥