This guide covers various deployment options for the Langroid Chat UI.
Before deploying, ensure you have:
- Built the frontend:
cd frontend && npm run build - Set up environment variables
- Tested the application locally
VITE_BACKEND_URL=https://your-backend-api.comOPENAI_API_KEY=your-openai-api-key
HOST=0.0.0.0
PORT=8000
ALLOWED_ORIGINS=https://your-frontend-domain.com- Install Vercel CLI:
npm i -g vercel - Build the frontend:
cd frontend && npm run build - Deploy:
vercel --prod - Set environment variable in Vercel dashboard
- Build the frontend:
cd frontend && npm run build - Drag and drop the
frontend/distfolder to Netlify - Or use Netlify CLI:
npm i -g netlify-cli netlify deploy --prod --dir=frontend/dist
- Install gh-pages:
npm install --save-dev gh-pages - Add to package.json scripts:
"predeploy": "npm run build", "deploy": "gh-pages -d dist"
- Deploy:
npm run deploy
-
Create a
railway.jsonin the backend directory:{ "build": { "builder": "NIXPACKS" }, "deploy": { "startCommand": "uvicorn main:app --host 0.0.0.0 --port $PORT" } } -
Deploy:
railway login railway up
-
Create a
render.yaml:services: - type: web name: langroid-chat-backend env: python buildCommand: "pip install -r requirements.txt" startCommand: "uvicorn main:app --host 0.0.0.0 --port $PORT"
-
Connect GitHub repo and deploy
-
Create
Procfilein backend directory:web: uvicorn main:app --host 0.0.0.0 --port $PORT -
Create
runtime.txt:python-3.11.0 -
Deploy:
heroku create your-app-name heroku config:set OPENAI_API_KEY=your-key git push heroku main
-
Create
Dockerfilein backend directory:FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . EXPOSE 8000 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
-
Build and run:
docker build -t langroid-chat-backend . docker run -p 8000:8000 --env-file .env langroid-chat-backend
Create docker-compose.yml in the root directory:
version: '3.8'
services:
frontend:
build: ./frontend
ports:
- "80:80"
environment:
- VITE_BACKEND_URL=http://backend:8000
depends_on:
- backend
backend:
build: ./backend
ports:
- "8000:8000"
env_file:
- ./backend/.env- Set up a Linux server
- Install Docker and Docker Compose
- Clone your repository
- Run:
docker-compose up -d - Set up Nginx as reverse proxy:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /ws {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /api {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}- SSL/TLS: Always use HTTPS in production
- Environment Variables: Never commit sensitive data
- Logging: Set up proper logging and monitoring
- Scaling: Consider using a load balancer for high traffic
- Database: For persistent chat history, add a database
- Rate Limiting: Implement rate limiting to prevent abuse
- CORS: Configure CORS properly for your domains
Consider adding:
- Sentry for error tracking
- LogRocket or FullStory for session replay
- New Relic or DataDog for performance monitoring
- Prometheus + Grafana for metrics