How to Deploy a Ruby App to Production with Git

16th May 2023

You can use GitPushLive to deploy ruby apps to your own servers. This allows you to choose from a large number of server providers and configurations to best meet your cost / performance requirements. It also has no lock-in and allows you to add additional databases and services as required without additional cost.


Deploying a Ruby App to your GitPushLive Server


1. Pull in our Ruby sample app with the following commands

# clone our demo repository
git clone [email protected]:GitPushLive/ruby-sample.git
# change into the project folder
cd ruby-sample
# configure
bundle config set --local path 'vendor/bundle'
# install dependencies
bundle install
# test the app
bundle exec ruby app.rb


If you open your web browser at http://127.0.0.1:3000 You should see the simple output of “Hello World!”

You can now press ctrl + c to stop the ruby app from running.

2. Deploy this app to your server ( below presumes your server is called d1.server.com )

# add your git remote 
git remote add live [email protected]:ruby-sample
# push it live
git push live

If you open your web browser at http://ruby-sample.d1.server.com you should now see the app running on your live server

Sample Project Explained.

The above code is able to run because

  • Dokku sets up an Nginx reverse proxy to manage your traffic from the above custom domain.

  • The Ruby environment is setup with the Dockerfile here.  

  • Dokku runs the command held in the Procfile here.

  • The app knows which port to listen on by using the PORT environmental variable here.

The above app is a very basic sinatra app with a single endpoint. However the principle should be the same for more complex applications. We plan to add more tutorials on how to use databases from with your ruby apps.


Other Deployment Options


Manual Deployment

Deploying Ruby apps can be tricky as you need to setup some kind of server, process manager, reverse proxy etc. To do this without GitPushLive you can follow something like the Digital Ocean Tutorial Here.

Using a Proprietary PAAS Solution

Another way is to sign up to one of the many App platforms to host it for you, you’ll be tied to their eco system so have to pay extra for add-ons like database, backups etc. However this may be a good option if your app fits within their free tier or vendor lock-in ins’t a concern. For Ruby applications Heroku has been a popular option in the past and offers similar ergonomics to Dokku, without the savings associated with using your own VM’s.