# 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) 1. Go to https://railway.app/dashboard 2. Click "New Project" 3. Select "Deploy from GitHub repo" 4. Choose your `aethex.live` repository 5. Configure: - **Build Command**: `npm install && npm run build` - **Start Command**: `npm start` - **Port**: `3000` ### Option 2: Deploy with Railway CLI ```bash # 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 1. Go to your Railway project dashboard 2. Click "Variables" tab 3. 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: 1. In your Railway project, click "Database" 2. Select **PostgreSQL** 3. Railway will automatically set `DATABASE_URL` environment variable 4. Connect your app to the database ## Custom Domain 1. Go to Railway project → Settings 2. Look for "Domains" 3. Add your custom domain: `aethex.live` 4. 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.json` has all dependencies - Ensure Node version is 20+ (Railway default is recent) ### Stream not loading - Check `NEXT_PUBLIC_STREAM_URL` is 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: ```json { "$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: 1. **Increase Memory**: Railway Dashboard → Settings → Instance Size 2. **Add More Instances**: Set `numReplicas` in railway.json 3. **Add CDN**: Use Cloudflare in front of Railway 4. **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: 1. Push code to GitHub 2. Railway detects changes 3. Auto-builds and deploys 4. Preview deployments for pull requests Disable auto-deploy: Railway Dashboard → Settings → Auto Deploy ## Useful Railway Commands ```bash # 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 1. ✅ Deploy to Railway 2. ✅ Add custom domain 3. Implement real chat backend (Firebase/WebSocket) 4. Add user authentication 5. Set up analytics 6. 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! 🚀**