Railway Deployment
Deploy full-stack applications with databases, background workers, and automatic scaling on Railway.
Setup Time
~3 minutes
Complexity
Easy
Best For
Full-Stack Apps
Overview
Railway is a modern deployment platform that makes it easy to deploy full-stack applications with databases and background services. QODRYX integrates deeply with Railway to provide automated deployments, database provisioning, and environment management.
Databases Included
Railway offers managed PostgreSQL, MySQL, MongoDB, and Redis databases with automatic backups and connection pooling.
Prerequisites
- A Railway account (free tier with $5 credit)
- A GitHub repository connected to QODRYX
- Your application with a valid
Dockerfileor supported runtime
Step 1: Connect Railway
Connect your Railway account to QODRYX:
- Go to Settings β Integrations in your QODRYX dashboard
- Find Railway in the deployment platforms section
- Click Connect and authorize QODRYX
- Select the Railway project or create a new one
Step 2: Configure Deployment
Configure your project for Railway deployment:
deployment:
provider: railway
# Project settings
project:
name: my-fullstack-app
# Services to deploy
services:
# Main web service
- name: web
source: ./
build:
dockerfile: Dockerfile
healthcheck:
path: /api/health
interval: 30s
scaling:
min: 1
max: 10
# Background worker
- name: worker
source: ./worker
command: npm run worker
# Databases
databases:
- name: postgres
type: postgresql
- name: redis
type: redis
# Environment variables
environment:
production:
- DATABASE_URL # Auto-injected from postgres
- REDIS_URL # Auto-injected from redis
- API_SECRETStep 3: Database Configuration
QODRYX can automatically provision and configure databases on Railway:
PostgreSQL
databases:
- name: postgres
type: postgresql
version: "15"
# Connection settings
connection:
pooling: true
max_connections: 100
# Backups
backup:
enabled: true
retention: 7d
# The DATABASE_URL is automatically injectedRedis
databases:
- name: redis
type: redis
version: "7"
# Memory settings
memory:
max: 256mb
eviction_policy: allkeys-lru
# The REDIS_URL is automatically injectedMulti-Service Deployments
Deploy multiple services in a single Railway project:
services:
# API Server
- name: api
source: ./apps/api
port: 3000
healthcheck:
path: /health
# Web Frontend
- name: web
source: ./apps/web
port: 3001
depends_on:
- api
# Background Worker
- name: worker
source: ./apps/worker
command: npm run worker
replicas: 2
# Cron Jobs
- name: scheduler
source: ./apps/scheduler
command: npm run cron
schedule: "0 * * * *" # Every hourCustom Domains
Configure custom domains for your Railway services:
services:
- name: web
source: ./
# Custom domains with automatic SSL
domains:
- myapp.com
- www.myapp.com
- api.myapp.comAutomatic SSL
Railway automatically provisions SSL certificates for all custom domains using Let's Encrypt.
Environment Management
Manage environment variables across different environments:
environment:
# Shared across all environments
shared:
- NODE_ENV
- LOG_LEVEL
# Production-specific
production:
- API_SECRET
- STRIPE_SECRET_KEY
# Staging-specific
staging:
- API_SECRET
- STRIPE_TEST_KEY
# Sync secrets from QODRYX vault
secrets:
sync: trueAuto-Scaling
Configure automatic scaling based on load:
services:
- name: api
source: ./
scaling:
# Minimum and maximum instances
min: 1
max: 10
# Scale up when CPU > 70%
cpu_threshold: 70
# Scale up when memory > 80%
memory_threshold: 80
# Cooldown between scaling events
cooldown: 60sDeployment Triggers
Configure automatic deployments:
# Deploy to production
qodryx deploy --provider railway --env production
# Deploy specific service
qodryx deploy --provider railway --service api
# Deploy with database migration
qodryx deploy --provider railway --migrate
# View deployment logs
qodryx logs --provider railway --service api --followKey Features
Auto-detects runtime and builds
PostgreSQL, MySQL, MongoDB, Redis
Services communicate securely
One-click rollback to any version
Troubleshooting
Build Failures
- Dockerfile not found: Ensure Dockerfile is in the service source directory
- Port not detected: Explicitly set the
PORTenvironment variable - Out of memory: Increase memory limits in Railway dashboard
Database Connection Issues
- Verify
DATABASE_URLis correctly injected - Check connection pooling settings for high-traffic apps
- Ensure your app handles connection retries
Cold Starts
Railway may spin down inactive services. Set min: 1 in scaling config to keep services always running.