4.6 KiB
4.6 KiB
Deploying aethex.live to Railway
Railway is a great platform for hosting full-stack applications. Here's how to get your streaming platform running on Railway.
Prerequisites
- Railway.app account (https://railway.app)
- GitHub repository connected to Railway
- Your streaming provider HLS URL
Quick Deploy
Option 1: Deploy from GitHub (Easiest)
- Go to https://railway.app/dashboard
- Click "New Project"
- Select "Deploy from GitHub repo"
- Choose your
aethex.liverepository - Configure:
- Build Command:
npm install && npm run build - Start Command:
npm start - Port:
3000
- Build Command:
Option 2: Deploy with Railway CLI
# Install Railway CLI
npm install -g @railway/cli
# Login to Railway
railway login
# Initialize Railway in your project
railway init
# Deploy
railway up
Environment Variables in Railway
- Go to your Railway project dashboard
- Click "Variables" tab
- Add these environment variables:
NEXT_PUBLIC_STREAM_URL=your-hls-stream-url.m3u8
NODE_ENV=production
Optional (if implementing backends):
# Firebase
NEXT_PUBLIC_FIREBASE_API_KEY=...
NEXT_PUBLIC_FIREBASE_PROJECT_ID=...
# Database
DATABASE_URL=postgresql://...
# Chat
NEXT_PUBLIC_WEBSOCKET_URL=wss://your-railway-app.railway.app
# Authentication
NEXTAUTH_URL=https://your-railway-domain.railway.app
NEXTAUTH_SECRET=your-secret-key
Database Setup (Optional)
If you want to use a database on Railway:
- In your Railway project, click "Database"
- Select PostgreSQL
- Railway will automatically set
DATABASE_URLenvironment variable - Connect your app to the database
Custom Domain
- Go to Railway project → Settings
- Look for "Domains"
- Add your custom domain:
aethex.live - Update your DNS records to point to Railway's nameservers
Or use CNAME:
Name: aethex
Type: CNAME
Value: (provided by Railway)
Monitoring & Logs
- View Logs: Railway Dashboard → Logs tab
- Monitor Resources: Railway Dashboard → Metrics tab
- Configure Alerts: Railway Dashboard → Settings → Alerts
Troubleshooting
Build fails
- Check build logs in Railway dashboard
- Verify
package.jsonhas all dependencies - Ensure Node version is 20+ (Railway default is recent)
Stream not loading
- Check
NEXT_PUBLIC_STREAM_URLis set correctly - Verify HLS URL is publicly accessible
- Check if CORS is enabled on your stream provider
App crashes
- View logs in Railway for error messages
- Check if PORT is correctly set to 3000
- Ensure memory limit is sufficient (512MB+ recommended)
Domain issues
- DNS changes can take 24-48 hours to propagate
- Verify CNAME/A record points to Railway
- Test with
nslookup aethex.live
Advanced Railway Configuration
Create a railway.json file for automatic deployments:
{
"$schema": "https://railway.app/schema.json",
"build": {
"builder": "nixpacks"
},
"deploy": {
"startCommand": "npm start",
"restartPolicyType": "on_failure",
"restartPolicyMaxRetries": 3,
"numReplicas": 1,
"healthcheckPath": "/",
"healthcheckTimeout": 30
}
}
Scaling
As your stream grows:
- Increase Memory: Railway Dashboard → Settings → Instance Size
- Add More Instances: Set
numReplicasin railway.json - Add CDN: Use Cloudflare in front of Railway
- Database Optimization: Add indexes, optimize queries
Cost Optimization
Railway charges per hour for usage:
- CPU: $0.07/month per 1 CPU per hour active
- Memory: $0.07/month per 1GB per hour active
Estimate: ~$5-15/month for a small streaming app
Tips:
- Stop unused projects
- Use Railway's free tier ($5 credit/month)
- Monitor resource usage in Metrics tab
- Optimize build size: Use production builds
CI/CD
Railway automatically deploys when you push to main:
- Push code to GitHub
- Railway detects changes
- Auto-builds and deploys
- Preview deployments for pull requests
Disable auto-deploy: Railway Dashboard → Settings → Auto Deploy
Useful Railway Commands
# View project status
railway status
# View logs
railway logs
# Open dashboard
railway open
# Set environment variable
railway variables set NEXT_PUBLIC_STREAM_URL=your-url
# Deploy specific branch
railway deploy --branch staging
Next Steps
- ✅ Deploy to Railway
- ✅ Add custom domain
- Implement real chat backend (Firebase/WebSocket)
- Add user authentication
- Set up analytics
- Monitor stream performance
Support
- Railway Docs: https://docs.railway.app
- Next.js on Railway: https://docs.railway.app/guides/nextjs
- Community: https://discord.gg/railway
Your stream is now on Railway! 🚀