Back
Question
Asked

How should I host my rails apps?

I built a few different rails apps locally and am ready to deploy them but I'm not sure how I should deploy them (especially since I have 2 that I want to ship on the same server). 

Some thoughts I had:

  • Digital Ocean VPS and manually install ruby, nginx, passenger etc and allocate resources?
  • Use Digital Ocean apps functionality?
  • - This one seems more expensive $24/mo but not sure

Admittedly, I'm still learning the rails devops side of things and coming from PHP (which was much simpler). 

Ideally would like to keep cost down below $30/mo until I can prove it will make it back. 


Hetzner + Kamal + Cloudflare?

Yeah, I saw that combo in the Kamal demo - maybe I am still to new to understand. Am I able to run multiple rails apps on the same VPS with it?

Yes! You definitely can run multiple Rails apps in the same server, either with Kamal or with Capistrano.

Kamal has a bit of a steep learning curve, though, but it seems like it's the direction Rails 7.1+ / Rails 8 is going to push for. You'll need to become familiar with Docker and Traefik to understand what's going on.

Me personally, until now I've been using Capistrano + a DigitalOcean droplet / AWS instance. But Capistrano has a learning curve of its own (mostly: getting really comfortable with Unix, Nginx config, security hardening, and general sysadmin work)

If you want really cheap instances for small apps, I suggest AWS Lightsail, they have instances starting at $3.5/mo, and they're really easy to spin up as well.

I'm now in the process of migrating my apps from Capistrano to Kamal, and plan to deploy multiple in a single AWS instance.

Join the WIP Ruby chat! We've been having interesting discussions about this very topic lately t.me/wipruby

More general solutions that are much cheaper and apply to hosting apps of any language:
- AWS Elastic Beanstalk (works like Heroku, you don’t need to worry about managing deployment config, autoscaling also handled for you)
- I’ve heard good things about Render and Supabase but I’ve never tried them

It sounds like you’re new to the language or just getting started in some way, so I’d avoid things like kamal and manually maintaining your own VMs. Use a platform to handle all of that for you in the beginning and only move to a more complex solution later once you can justify it.

Thanks for all the replies and help. I am testing out Hatchbox.io and DigitalOcean! Definitely smooth so far.

if you're just starting out, do it by hand, host on hetzner, after installing save all the installation stuff, and transform it to an ansible script for later installs.

Digital Ocean VPS or Hetzner + Cloudflare is hard to beat.

I have run dozens of containers on DO droplets for years, and they are hard to beat. I heard equally good things about Hetzner (I'm also told they are cheaper).

Host them somewhere, does not matter. Or do you want to actively maintain them?

Some affordable options:

• shared hosts/VPS
- Passenger

• full-service deployment companies
- Engine Yard
- Rails Machine

• cloud deployment services
- Engine Yard Cloud
- Heroku

As a beginner, I recommend Heroku as it is ridiculously easy to deploy as long as your source code is under version control with Git. Also because Heroku was initially built for Ruby, and is written in Rails.

For hosting multiple Rails apps on the same VPS, I really like dokku. It's FOSS.
Once you've installed it on your VPS, it allows you to git push your code to the server, just like heroku.

I'll suggest something else. Just use one project per VM with Kamal.

(Someone wrote here that Kamal can manage multiple apps but it's not designed this way and it's a bit of a hack.)

This way you can host 2 projects for smth around $10 on two VMs, each with its own database.

I added this style of deployment to my template Business Class, so I can run two commands and be up and running.

It works quite nicely.

I'll say Heroku is still the quickest and easiest option, but it can get pricey fast and don't expect much support.

I'm currently using fly.io for my projects. A little bit more work, but a little cheaper and their docs/forums are pretty helpful. That said, once a project gets any sort of scale, I'll be moving my PG database to crunchybridge.com and let them manage the db for me.