Deploying to Railway
Deploy your EreoJS application to Railway for simple, managed hosting.
Prerequisites
- A Railway account
- Your project in a Git repository (GitHub, GitLab, or Bitbucket)
Connect Your Repository
- Log in to the Railway dashboard
- Click New Project > Deploy from GitHub repo
- Select your EreoJS repository
- Railway detects Bun automatically and begins the first deploy
Build and Start Commands
Railway auto-detects Bun projects. If you need to customize the commands, set them in the Railway dashboard under Settings > Build & Deploy:
| Setting | Value |
|---|---|
| Build command | bun run build |
| Start command | bun ereo start |
| Watch paths | /src/**, /routes/** |
Alternatively, configure via a railway.json in your project root:
{
"build": {
"builder": "NIXPACKS",
"buildCommand": "bun run build"
},
"deploy": {
"startCommand": "bun ereo start",
"healthcheckPath": "/api/health",
"restartPolicyType": "ON_FAILURE"
}
}Environment Variables
Set environment variables in the Railway dashboard:
- Go to your project > Variables
- Add your variables:
NODE_ENV=production
DATABASE_URL=postgres://...
SESSION_SECRET=your-secretOr use the Railway CLI:
railway variables set DATABASE_URL="postgres://..."
railway variables set SESSION_SECRET="your-secret"Variables are encrypted and injected at runtime.
Custom Domain
Add a custom domain in the Railway dashboard:
- Go to Settings > Networking > Custom Domain
- Enter your domain (e.g.,
app.example.com) - Add the provided CNAME record to your DNS provider
- Railway provisions an SSL certificate automatically
Database
Add a database service directly in Railway:
- In your project, click New > Database
- Choose PostgreSQL, MySQL, Redis, or MongoDB
- Railway creates the database and sets the connection URL as an environment variable automatically
Reference the variable in your EreoJS config:
const db = new Database(process.env.DATABASE_URL)Railway CLI
Install the CLI for command-line management:
npm install -g @railway/cli
railway loginDeploy from your local machine:
railway upView logs:
railway logsScaling
Railway handles scaling automatically based on your plan. For manual control:
- Replicas --- Configure in Settings > Scaling
- Resources --- Set memory and CPU limits in the dashboard
- Regions --- Select your preferred deployment region
Continuous Deployment
Railway deploys automatically on every push to your connected branch (usually main). To change the deploy branch or add preview environments for pull requests, configure in Settings > Build & Deploy.