3
13 Comments

Ruby on Rails & Digital Ocean

I'm looking to migrate my Ruby on Rails app from Heroku to Digital Ocean. I don't have any dev-ops experience and am very confused on where to start.

Does anyone have any beginner tutorials or links I could work through?

on October 6, 2020
  1. 3

    You're lucky, Digital Ocean just launched "App Platform" - https://www.digitalocean.com/blog/introducing-digitalocean-app-platform-reimagining-paas-to-make-it-simpler-for-you-to-build-deploy-and-scale-apps/

    I think this makes everything a lot easier for you!

    1. 2

      Wow, what timing! I'll definitely check this out. I wonder how it compares to HatchBox.

  2. 2

    If you are already using Heroku, I would highly recommend Dokku. There is a one click image for it, and its literally a self-hosted version of Heroku. Just create the app, install the postgres plugin, create the postgres db and link it, and finally git push!

    1. 1

      I've read that dokku doesn't scale past one instance. Is that true? If not, how is that managed?

      1. 1

        You're correct, you could scale your app to more expensive plans, but if thats not enough, then you can check out CapRover which is similar to Dokku but has Docker Swarm built in for scaling

    2. 1

      dokku is awesome!

  3. 2

    I migrated my Rails app from AWS to DigitalOcean last week. It wasn't bad at all. I run it in a docker container, so that made it easier.

    DigitalOcean has a droplet with Rails already installed. https://marketplace.digitalocean.com/apps/ruby-on-rails

    For the database, you can either run it on the droplet itself or use DigitalOcean's managed database. To deploy I gave the user on my droplet a deploy SSH key with read-only access to my project repo on github.
    https://docs.github.com/en/free-pro-team@latest/developers/overview/managing-deploy-keys

    1. 1

      Coming from AWS already means you have way more experience with this kind of stuff! But that's good to know about the droplet. Thanks for the links.

  4. 1

    I have heroku for my tiny RoR app and I have looked at migrating off heroku many times, but the time and feature cost is just not worth it in my humble opinion.

    With DO:
    you gotta setup your own firewall and many other security tasks (configure user accounts to control access. You shouldn't run everything as root) so your server doesn't get hacked.

    You gotta setup your SSH keys so you can talk to the server.

    You gotta put in some process management tooling such that if your rails app crashes, you can restart the process.

    You probably need to configure up nginx to serve static assets from your rails app.

    You gotta figure out how to orchestrate sidekiq or your fav background processing tool. so when you push your code to git, the web process and job process all are updated with the fresh code.

    Then on the db stack, you may need to setup your own redis server (or configure it to run on the same machine as your web and jobs box.

    DO offers managed dbs now with daily backups. so thats kinda nice I guess.

    You also should probably either script up (meaning configure the firewall, and do all of the steps above with one bash line) creating new fresh boxes in case your current box gets corrupted, hacked, or just dies.

    DO also is famous for losing customer data (google "digital ocean lost all of my data" and you will find many articles), so I would setup off-site backups of your db (and if you don't script up setting up a DO droplet, offsite backups of your droplets).

    All of this would probably take 40-120 hours (as someone who also isn't hyper experienced with devops and have all of these scripts ready).

    1. 1

      All of this would probably take 40-120 hours (as someone who also isn't hyper experienced with devops and have all of these scripts ready).

      That is enough for me to not want to manage something like this on my own. Thanks for the details!

      I'm thinking if I go down this route I would definitely go with HatchBox, Render, or their DO's new PaSS.

  5. 1

    Just curious, have you tried Render? Kinda like Heroku, just much cheaper.

    1. 1

      I hadn't heard of it, but it looks promising. Heroku-like PaSS but about half the cost. I can see this getting pricey if I scale horizontally a ton, but for now this might be the best approach.

      1. 1

        Did you try Render out for a Rails app? I'm curious about it.