Railway is the simplest option for deploying Maillayer. It handles databases, environment variables, and deployments in one place—no server management required.
Why Railway?
- One-click MongoDB and Redis setup
- Auto-deploys from GitHub
- Built-in logging and monitoring
- No Docker or server knowledge needed
- Generous free tier to get started
Prerequisites
- A GitHub account
- A Railway account (sign up here — get $20 in credits)
- Maillayer repository forked to your GitHub
Step 1: Create a New Project
- Log into Railway and click New Project
- Select Deploy from GitHub repo
- Choose your forked Maillayer repository
- Railway will automatically detect the Dockerfile
Step 2: Add MongoDB Database
- In your project, click New → Database → Add MongoDB
- Railway will provision a MongoDB instance
- Copy the
MONGO_URLfrom the MongoDB service's Variables tab
Step 3: Add Redis Database
- Click New → Database → Add Redis
- Railway will provision a Redis instance
- Copy the
REDIS_URLfrom the Redis service's Variables tab
Step 4: Configure Environment Variables
Click on your Maillayer service, go to Variables, and add:
NODE_ENV=production
BASE_URL=https://your-app.up.railway.app
NEXTAUTH_SECRET=your-secret-key-minimum-32-characters
TRACKING_SECRET=your-tracking-secret
MONGODB_URI=<paste MongoDB URL from Step 2>
REDIS_URL=<paste Redis URL from Step 3>
Railway automatically provides the database URLs as reference variables. You can use ${{MongoDB.MONGO_URL}} syntax to reference them directly.
Step 5: Deploy
- Railway auto-deploys when you push to your main branch
- Click Deploy to trigger a manual deployment
- Wait 3-5 minutes for the build to complete
- Click the generated URL to access your Maillayer instance
Step 6: Add Custom Domain (Optional)
- Go to Settings → Domains
- Click Generate Domain for a free
*.up.railway.appsubdomain - Or click Custom Domain and add your own domain
- Update your
BASE_URLenvironment variable to match
Monitoring & Logs
- View real-time logs in the Deployments tab
- Monitor resource usage in the Metrics tab
- Railway restarts crashed services automatically
Estimated Costs
| Resource | Free Tier | Paid |
|---|---|---|
| Compute | $5 credit/month | ~$5-10/month |
| MongoDB | Included | ~$5-7/month |
| Redis | Included | ~$3-5/month |
Total: Free to start, ~$13-22/month for production workloads.
Troubleshooting
Build fails with memory error
- Railway's free tier has limited memory. Upgrade to a paid plan or reduce build concurrency.
Workers not starting
- Check logs for connection errors. Ensure
MONGODB_URIandREDIS_URLare correctly set.
Can't connect to database
- Verify you're using the internal Railway URL, not the public one.
