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 Dockerfile or supported runtime

Step 1: Connect Railway

Connect your Railway account to QODRYX:

  1. Go to Settings β†’ Integrations in your QODRYX dashboard
  2. Find Railway in the deployment platforms section
  3. Click Connect and authorize QODRYX
  4. Select the Railway project or create a new one

Step 2: Configure Deployment

Configure your project for Railway deployment:

qodryx.config.yaml
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_SECRET

Step 3: Database Configuration

QODRYX can automatically provision and configure databases on Railway:

PostgreSQL

qodryx.config.yaml
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 injected

Redis

qodryx.config.yaml
databases:
  - name: redis
    type: redis
    version: "7"
    
    # Memory settings
    memory:
      max: 256mb
      eviction_policy: allkeys-lru
      
    # The REDIS_URL is automatically injected

Multi-Service Deployments

Deploy multiple services in a single Railway project:

qodryx.config.yaml
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 hour

Custom Domains

Configure custom domains for your Railway services:

qodryx.config.yaml
services:
  - name: web
    source: ./
    
    # Custom domains with automatic SSL
    domains:
      - myapp.com
      - www.myapp.com
      - api.myapp.com

Automatic SSL

Railway automatically provisions SSL certificates for all custom domains using Let's Encrypt.

Environment Management

Manage environment variables across different environments:

qodryx.config.yaml
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: true

Auto-Scaling

Configure automatic scaling based on load:

qodryx.config.yaml
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: 60s

Deployment Triggers

Configure automatic deployments:

Terminal
# 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 --follow

Key Features

Zero-Config Deploys

Auto-detects runtime and builds

Managed Databases

PostgreSQL, MySQL, MongoDB, Redis

Private Networking

Services communicate securely

Instant Rollbacks

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 PORT environment variable
  • Out of memory: Increase memory limits in Railway dashboard

Database Connection Issues

  • Verify DATABASE_URL is 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.