How to Deploy a Ruby App in 2020

Joseph Cooper
KintoHub
Published in
4 min readSep 16, 2020

Deploying a Ruby app has evolved over the last decade. There are many traditional ways to deploy ruby into the cloud such as using virtual machines or docker containers, but now you can even more easily get online and update your ruby service for free. This guide will show you how to deploy a ruby app online for free and how to update the app’s code with no downtime.

Getting Started With Ruby

  1. Install git
  2. Install ruby
  3. This guide requires a free GitHub account
  4. This guide requires a free KintoHub account

Deploy A Ruby App To The Cloud

In the following steps, we are going to use KintoHub to deploy your app to the Cloud. The first thing we need to do is copy the example code onto your GitHub account. You can do this by going to the following repository and click Use this template at the top right.

https://github.com/kintohub-examples/ruby-api

Once you have created the ruby-app example within your Github account, login to your KintoHub account and do the following:

  1. Click on the Create Service at the top right
  2. Choose Web App from the service type list
  3. Connect and give access to your ruby-app on your Github account. Then select that repository.
  4. Change the Language from `Dockerfile` to `Ruby`
  5. Choose Language Version 2.5
  6. Set the Build Command to `gem install bundler && bundle install`
  7. Set the Start Command to `bundle exec ruby app.rb`
  8. Set the port to 8000
  9. Click Deploy at the top right.

After one minute, your app should be built and deployed and accessible with a URL at the bottom of the logs.

Good Work! You Rock.

After opening the URL you can add the extension hello/stranger and you will get the response

 {“message”:”Hello stranger”}

Update your Ruby App

Now let’s say you want to make some changes to your app and you want to push an update to your users. First, we need to clone the code to your local machine. Make the changes, then push the new code.

  1. Go to your Github repository and click on Code and copy the URL.
  2. Open a terminal and run git clone {paste-your-repo-here}
  3. Open up the app.rb file and change /hello/ to /goodbye/
Your code should look like this after!

Test Your Ruby App Locally

Before pushing any code, you must test it! To test your ruby app, run the following command.

  1. gem install bundler && bundle install
  2. bundle exec ruby
  3. Open your browser to https://localhost:8000/goodbye/stranger and you should see a successful response
After starting the app in step (2) — it should look like this!

Now that we know your code works, you can push it to Github with the following commands:

git add . && git commit -m ":alien: refak(App): goodbye endpoint" && git push

A successful push looks like this!

Deploy Your changes

Finally, we need to deploy the changes you just tested which should be working correctly. Go back to KintoHub and do the following.

  1. Click on your ruby-app service
  2. Click Trigger Deploy at the top right

After a minute, you should see again a successful message at the bottom with the URL to access. When you trigger a deployment on KintoHub, it does not take down your old version until your new version is live and traffic has been redirected to it. This is known as a no-downtime deployment.

What’s Next?

KintoHub comes packed with many additional features to debug and enrich your Ruby App.

Conclusion

That’s it! Within a few minutes, you should have deployed and updated your Ruby App. If you have any issues with this example or want to learn more, please join us on Discord. There are also more advanced guides that can be found here.

--

--