Cuber: a Capistrano alternative for deploying Rails applications on Kubernetes
Marco Colli
Posted on July 13, 2022
Cuber is an automation and deployment tool written in Ruby: it is similar to Capistrano, but it deploys on Kubernetes, so you don’t need to configure all the servers and it’s more scalable.
Basically you can deploy your application by defining a Cuberfile
(a few lines of Ruby code, like a Capfile for Capistrano) and then typing cuber deploy
in your terminal.
Cuber has been designed for monolithic Rails applications, but it can actually deploy any application, in any language and framework.
It has all the features needed to run an application in production.
Here’s an example Cuberfile
that you can use to deploy any Rails app on Kubernetes:
app 'myapp'
repo '.'
buildpacks 'heroku/buildpacks:20'
image 'username/myapp'
dockerconfig 'dockerconfig.json'
kubeconfig 'kubeconfig.yml'
migrate 'rails db:migrate', check: 'rake db:abort_if_pending_migrations'
proc :web, 'bundle exec puma', scale: 3
proc :worker, 'bundle exec sidekiq', scale: 2
cron :mytask, '@daily', 'rake mytask'
env 'RAILS_ENV', 'production'
env 'RAILS_LOG_TO_STDOUT', 'enabled'
env 'RAILS_SERVE_STATIC_FILES', 'enabled'
env 'RAILS_MASTER_KEY', File.read('config/credentials/production.key').strip, secret: true
That's it. Save that file in a directory (usually your application root), type cuber deploy
and let the magic happen.
There is also lot of information and technical documentation on the project website.
Finally note that Kubernetes can be 80% cheaper than Heroku or other PaaS, because it is bare infrastructure. Kubernetes is also offered by most cloud providers, and thus you avoid lock-in with a single service provider.
Posted on July 13, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.