mirror of
https://github.com/openai/whisper.git
synced 2025-11-24 06:26:03 +00:00
Backend Updates: - Add lazy loading for Whisper model (faster startup) - Use environment variables for port and config - Add root endpoint for health checking - Configure CORS for production - Add tempfile support for uploads - Update to support gunicorn production server - Add Procfile for Heroku/Railway compatibility Frontend Updates: - Optimize Vite build configuration - Add production build optimizations - Enable minification and code splitting - Configure preview server for production Configuration: - Add .env.example files for both frontend and backend - Create railway.toml for Railway deployment - Add Procfile for process management - Setup environment variable templates Documentation: - Create comprehensive RAILWAY_DEPLOYMENT.md guide - Include step-by-step deployment instructions - Add troubleshooting section - Include cost breakdown - Add monitoring and maintenance guide Dependencies: - Add gunicorn for production WSGI server Ready for Railway deployment with: - Free $5/month credit - Automatic scaling - 24/7 uptime - Custom domain support (optional)
6.5 KiB
6.5 KiB
Railway Deployment Guide
Complete step-by-step guide to deploy your Farsi Transcriber web app to Railway.
Prerequisites
- GitHub Account - To connect your repository
- Railway Account - Free signup at https://railway.app
- Git - Already have this since you're using it
Step 1: Prepare Your Code for Deployment
1.1 Make sure all files are committed
cd /home/user/whisper
git status
git add .
git commit -m "Ready for Railway deployment"
1.2 Push to GitHub
If you haven't already, push your fork to GitHub:
git push origin claude/review-repo-011CV3PVcA7ZSCTW2YquuMB8
Step 2: Create Railway Account
- Go to https://railway.app
- Click "Login with GitHub"
- Authorize Railway to access your GitHub account
- You'll get $5 monthly credit for free ✅
Step 3: Create Backend Service (Flask API)
3.1 Create a new project
- In Railway dashboard, click "Create New Project"
- Select "GitHub Repo"
- Select your whisper repository
- Railway will auto-detect it as Python
- Configure:
- Root Directory:
farsi_transcriber_web/backend - Start Command:
gunicorn --workers 2 --bind 0.0.0.0:$PORT app:app
- Root Directory:
3.2 Set environment variables
In the Railway dashboard for your backend:
- Go to Variables
- Add:
FLASK_ENV=production FLASK_DEBUG=False PYTHONUNBUFFERED=1 PORT=5000
3.3 Deploy
- Click Deploy
- Wait for deployment (takes 2-3 minutes)
- Your backend URL will appear (e.g.,
https://farsi-api-prod.railway.app) - Copy this URL - you'll need it for the frontend
Step 4: Create Frontend Service (React)
4.1 Create another service in same project
- Go to your Railway project
- Click "Create New Service"
- Select "GitHub Repo"
- Select your whisper repository
- Configure:
- Root Directory:
farsi_transcriber_web - Build Command:
npm install && npm run build - Start Command:
npm run preview
- Root Directory:
4.2 Set environment variables
In the Railway dashboard for your frontend:
- Go to Variables
- Add:
(Replace with your actual backend URL from Step 3.3)VITE_API_URL=https://your-backend-url-here.railway.app VITE_APP_NAME=Farsi Transcriber
4.3 Deploy
- Click Deploy
- Wait for deployment (2-5 minutes depending on npm install)
- Your frontend URL will appear (e.g.,
https://farsi-web-prod.railway.app)
Step 5: Configure Services to Communicate
5.1 Link backend to frontend
- In Railway dashboard, select frontend service
- Go to Variables
- Update
VITE_API_URLwith your backend service domain - Deploy again
5.2 Test the connection
- Open your frontend URL
- Try to add a file and transcribe
- Check browser console for any errors
- If errors, check Railway logs (click service → Logs)
Step 6: Monitor Your Deployment
6.1 View logs
In Railway dashboard:
- Click your service
- Go to Logs tab
- See real-time logs as users interact with your app
6.2 Check health
# Check if backend is running
curl https://your-backend-url.railway.app/health
# Should return:
# {"status": "healthy", "model_loaded": true, "environment": "production"}
6.3 Monitor usage
- Railway dashboard shows RAM, CPU, bandwidth usage
- Your $5 credit should last 1-3 months for personal use
Step 7: Custom Domain (Optional)
If you want a custom domain like farsi.yourdomain.com:
- Buy a domain on GoDaddy, Namecheap, etc.
- In Railway dashboard → Your app → Settings → Domains
- Add custom domain
- Update DNS records at your domain provider
- Railway will handle SSL certificate automatically
Troubleshooting
Issue: Backend showing error "Model not loaded"
Solution: First transcription loads the 769MB model (takes 1-2 min). Wait and try again.
Issue: Frontend can't reach backend
Solution:
- Check backend URL is correct in frontend variables
- Backend must be running (check Railway logs)
- CORS should be enabled (already configured)
Issue: Build fails
Solution:
- Check Railway build logs for errors
- Ensure
package.jsonhas all required dependencies - Run locally first:
npm install && npm run build
Issue: App runs slow
Solution:
- You're on free tier with limited resources
- Upgrade to paid tier ($5/month) for better performance
- Or wait for model to cache (subsequent transcriptions are fast)
Issue: Out of memory
Solution:
- Free tier has limited RAM
- Close unused tabs/apps
- Use smaller Whisper model (edit backend to use 'small' instead of 'medium')
Next Steps: Custom Domain Setup
Once stable, add your custom domain:
- Purchase domain
- Railway → Settings → Domains → Add Domain
- Update DNS CNAME records
- Railway auto-generates SSL certificate
Cost Breakdown
Free Tier ($5/month credit)
- ✅ 500 build minutes/month
- ✅ 100 GB bandwidth/month
- ✅ 6,000 compute unit hours
- ✅ More than enough for personal use
Your app will cost:
- Backend (Flask): ~$1-2/month
- Frontend (React): ~$0.50/month
- Total: ~$2/month (with free credit covering 2-3 months)
Useful Commands
Check if Railway CLI is installed
railway --version
Install Railway CLI
npm i -g @railway/cli
Deploy from command line
railway up
View logs
railway logs
What Happens Now
- ✅ Your app is live on Railway
- ✅ Free $5 monthly credit
- ✅ Auto-scaling (if you get traffic)
- ✅ 24/7 uptime
- ✅ Automatic SSL/HTTPS
- ✅ No infrastructure to manage
Monitor Your App
Visit your Railway dashboard regularly to:
- Check resource usage
- View logs
- Update environment variables
- Scale services if needed
- Monitor costs
After Deployment
Your app is now online! Share the URL with friends:
https://your-app-name.railway.app
Further Reading
Support
If you have issues:
- Check Railway logs (click service → Logs)
- Check browser console (F12 → Console tab)
- Visit Railway docs: https://docs.railway.app
- Check Flask logs for backend errors
Congratulations! Your Farsi Transcriber is now live! 🎉