Overview
Railway provides a simple platform for deploying containerized applications. Junkie can be deployed to Railway with minimal configuration.Prerequisites
- Railway account (railway.app)
- GitHub repository with Junkie code
- Required API keys and credentials
Deployment Steps
1. Create New Project
- Go to Railway Dashboard
- Click “New Project”
- Select “Deploy from GitHub repo”
- Authorize Railway to access your repository
- Select your Junkie repository
2. Configure Build Settings
Railway will automatically detect theDockerfile and use it for builds.
Build Configuration:
- Build Command: Automatically uses Dockerfile
- Start Command:
python main.py(defined in Dockerfile CMD) - Root Directory:
/(unless your code is in a subdirectory)
3. Set Environment Variables
Configure all required environment variables in Railway’s dashboard:Required Variables
Optional Variables
4. Add PostgreSQL Database
Railway offers managed PostgreSQL databases:- Click “New” in your project
- Select “Database” → “PostgreSQL”
- Railway will create a database and provide connection details
- Copy the
DATABASE_URLvariable - Set it as
POSTGRES_URLin your service environment variables
5. Deploy
- Click “Deploy” or push to your GitHub repository
- Railway will automatically:
- Clone your repository
- Build the Docker image
- Start the container
- Expose logs in the dashboard
Monitoring
View Logs
Railway provides real-time logs in the dashboard:- Go to your project
- Click on the service
- Navigate to the “Logs” tab
- Filter by log level or search for specific messages
Deployment Status
Monitor deployment status:- Building: Docker image is being built
- Deploying: Container is starting
- Active: Application is running
- Failed: Check logs for errors
Metrics
Railway provides basic metrics:- CPU Usage: Monitor CPU consumption
- Memory Usage: Track memory footprint
- Network: Incoming/outgoing traffic
Phoenix Tracing Integration
For detailed observability, enable Phoenix tracing:Automatic Deployments
GitHub Integration
Railway automatically deploys when you push to your repository:- Push changes to GitHub
- Railway detects the push
- Triggers a new build
- Deploys the updated container
Branch Deployments
Deploy different branches to different Railway services:mainbranch → Production servicestagingbranch → Staging servicedevbranch → Development service
Coolify Alternative
The project includes Coolify webhook integration in the CI/CD workflow (.github/workflows/main.yml).
If using Coolify instead of Railway:
- Set up Coolify webhook URL
- Add
COOLIFY_WEBHOOKandCOOLIFY_TOKENto GitHub secrets - Deployments trigger automatically after Docker image builds
Scaling
Vertical Scaling
Increase resources for your service:- Go to service settings
- Adjust vCPU and Memory allocations
- Railway will restart the service with new resources
Horizontal Scaling
Railway supports horizontal scaling:- Increase replica count in service settings
- Ensure your application supports multiple instances
- Use a shared database (PostgreSQL) for state
Custom Domains
Expose your service via a custom domain:- Go to service settings
- Click “Domains”
- Add a custom domain
- Update DNS records as instructed
Cost Optimization
Tips
- Right-size Resources: Start with minimal resources and scale as needed
- Reduce Debug Logging: Set
DEBUG_MODE=falsein production - Use Shared Databases: Railway’s PostgreSQL is cost-effective
- Monitor Usage: Track CPU/memory to avoid over-provisioning
Troubleshooting
Deployment Fails
Check build logs:- Go to “Deployments” tab
- Click on the failed deployment
- Review build output for errors
- Missing dependencies in
requirements.txt - Invalid Dockerfile syntax
- Git authentication issues (for Git-based dependencies)
Application Crashes
Check runtime logs:- Go to “Logs” tab
- Look for error messages or stack traces
- Missing environment variables
- Database connection failures
- Invalid API keys
Service Won’t Start
- Verify all required environment variables are set
- Check
POSTGRES_URLconnection string format - Test API keys locally before deploying
- Review logs for specific error messages
Next Steps
- Environment Setup - Configure production variables
- Monitoring - Set up Phoenix tracing
- Troubleshooting - Debug common issues