Ruby on Rails Deployment Without Heroku: Modern Alternatives
The End of Free Heroku (And Why That's Actually Good)
Heroku's decision to end their free tier sent shockwaves through the Rails community. For years, git push heroku main was the gold standard for getting Rails apps live with zero DevOps headaches. But here's the thing - Heroku's exit from the free hosting game has actually pushed developers toward better, more flexible deployment options.
If you're a Rails developer who's been living in the Heroku bubble, it's time to explore what's beyond the purple platform. Let's dive into the best alternatives for deploying Rails apps in 2024.
Why Move Beyond Heroku?
Don't get me wrong - Heroku is still a solid platform. But their pricing has become prohibitive for indie developers and small projects. A basic dyno now costs $7/month, and you'll quickly find yourself paying $25+ for anything production-ready.
More importantly, the Rails ecosystem has evolved. Modern deployment tools have made self-hosting Rails apps almost as simple as Heroku, but with better performance, lower costs, and more control.
Top Rails Deployment Alternatives
1. Railway: The Spiritual Successor
Railway feels like what Heroku should have become. It offers the same git-push deployment experience but with modern infrastructure and better pricing.
# Deploy to Railway in three commands
npm install -g @railway/cli
railway login
railway deploy
What makes Railway shine:
- Built-in PostgreSQL and Redis
- Automatic SSL certificates
- Usage-based pricing (you only pay for what you use)
- Built-in CI/CD with GitHub integration
- Excellent developer experience
Pricing starts at $5/month for the Pro plan, but you can often run small apps for under $10/month total.
2. DigitalOcean App Platform: Heroku-Like Simplicity
DigitalOcean's App Platform brings PaaS simplicity to their robust infrastructure. It's particularly great if you're already using DO for other services.
# app.yaml
name: my-rails-app
services:
- name: web
source_dir: /
github:
repo: your-username/your-rails-app
branch: main
run_command: bundle exec rails server -p $PORT
environment_slug: ruby
instance_count: 1
instance_size_slug: basic-xxs
databases:
- name: db
engine: PG
version: "13"
The App Platform handles:
- Automatic deployments from GitHub
- Built-in load balancing
- Managed PostgreSQL
- SSL certificates
- Easy environment variable management
3. Fly.io: Global Edge Deployment
Fly.io is perfect for Rails apps that need global distribution. They run your app on their global network, automatically placing instances close to your users.
# Get started with Fly
flyctl launch
flyctl deploy
Fly automatically generates a Dockerfile for your Rails app and handles the entire deployment pipeline. Their global network means your Rails app loads fast everywhere, not just in US-East-1.
Key benefits:
- Global edge deployment
- Automatic scaling
- Built-in Redis and PostgreSQL
- Competitive pricing
- Great for apps with international users
4. Render: Zero-Config Rails Hosting
Render has positioned itself as the direct Heroku replacement, with a focus on simplicity and developer happiness.
# render.yaml
services:
- type: web
name: my-rails-app
env: ruby
buildCommand: bundle install && bundle exec rails assets:precompile
startCommand: bundle exec rails server -p $PORT
envVars:
- key: DATABASE_URL
fromDatabase:
name: my-rails-app-db
property: connectionString
databases:
- name: my-rails-app-db
databaseName: my_rails_app_production
Render's selling points:
- Free tier for static sites and APIs
- Automatic deployments from GitHub
- Built-in SSL and CDN
- Managed PostgreSQL and Redis
- Simple, predictable pricing
Self-Hosting: Taking Full Control
For developers ready to level up their DevOps game, self-hosting on a VPS offers the best bang for your buck. Here's how to deploy Rails like a pro:
The Modern Rails Stack
# Basic VPS setup (Ubuntu 22.04)
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git build-essential
# Install Ruby via rbenv
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
rbenv install 3.2.0
rbenv global 3.2.0
# Install Node.js for assets
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install PostgreSQL
sudo apt install -y postgresql postgresql-contrib
Docker: The Game Changer
Docker has made Rails deployment incredibly consistent across environments:
# Dockerfile
FROM ruby:3.2-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update -qq && apt-get install -yq --no-install-recommends \
build-essential \
gnupg2 \
less \
git \
libpq-dev \
postgresql-client \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install gems
COPY Gemfile* ./
RUN bundle install
# Copy app code
COPY . .
# Precompile assets
RUN bundle exec rails assets:precompile
EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
Kamal: Rails 8's Secret Weapon
Rails 8 ships with Kamal, a deployment tool that makes self-hosting Rails apps incredibly simple:
# config/deploy.yml
service: my-rails-app
image: my-rails-app
servers:
web:
- 192.168.1.1
registry:
server: registry.digitalocean.com
username: your-username
password:
- REGISTRY_PASSWORD
env:
clear:
PORT: 3000
secret:
- RAILS_MASTER_KEY
# Deploy with one command
kamal deploy
Kamal handles:
- Docker image building and pushing
- Zero-downtime deployments
- SSL certificate management
- Load balancer configuration
- Database migrations
Making the Right Choice
Choosing the right deployment strategy depends on your priorities:
Choose Railway or Render if:
- You want the Heroku experience
- You're building MVPs or side projects
- DevOps isn't your thing (yet)
Choose Fly.io if:
- You have global users
- Performance is critical
- You want edge deployment
Choose self-hosting if:
- You want maximum control and customization
- You're cost-conscious for larger apps
- You're ready to learn DevOps
The Bottom Line
Heroku's free tier ending was a wake-up call, but it's pushed the Rails community toward better solutions. Whether you choose a managed platform or go the self-hosting route, you'll end up with more flexibility, better performance, and often lower costs.
The Rails deployment landscape has never been better. Pick the option that fits your skill level and project needs, and start shipping your apps to the world.
Remember: the best deployment platform is the one you actually use. Start simple, learn as you go, and scale up your DevOps skills as your projects grow.
Alex Hackney
DeployMyVibe