In Ruby ecosystem the most popular deployment automation tool is Capistrano. Recently I came across a promising alternative GitHub - mattbrictson/tomo: A friendly CLI for deploying Rails apps ✨. I really liked the simplicity of tomo compared to Capistrano and so I was considering it for deployment but considering my context and requirements (ref: tomo examples for non-Rails projects · mattbrictson/tomo · Discussion #457 · GitHub) unfortunately I cannot use it. And so I am now left with the option to manually manage my deployment. As part of that I was compiling the steps that should be involved like
SSH to remote machine and do following:
- Setup folder structure (one-time)
- Install rvm (one-time)
- Install Ruby (one-time)
- Run
bundle
for installing application’s gems. (first-time and whenever new gems are introduced) - Run rake tasks (for e.g. to run data migration script or compile assets)
etc.
While doing that compilation I got a thought can dry-rb gems be considered for automating some of the tasks mentioned above? For e.g. when using Capistrano with Rails application, on remote machines it generates and manages following folder structure
app-name
current
<the most recently pushed code meant for making live>
releases
<timestamp-1 folder>
<the version of code which was live on timestamp-1>
<timestamp-2 folder>
<the version of code which was live on timestamp-2>
repo
<codebase's git info>
revisions.log
<Entries like following>
Branch feature_10 (at <commit-id>) deployed as release 20230425192237 by
shared
bundle
ruby
<ruby-[version-number]-folder>
ruby language code
<ruby-[version-number]-folder>
ruby language code
config
database.yml
secrets.yml
log
<log files>
public
assets
<minified assets>
tmp
vendor
So can dry-rb be utilized for implementing a sort of DSL which can help in automating tasks like following?
- create the folder structure
- run
bundle
- run rake tasks
- setup env variables
- managing current and previous releases like if
current
folder contains code deployed onAug 02, 2024 9:30 am
and new a deployment is to be done onAug 02, 2024 12:30 am
, then the DSL takes care of movingcurrent
folder code to202408020930
folder and copying the new code tocurrent
folder. And makingreleases
folder retain only a pre-defined number of recent releases, say retain only 5 releases.
Above shown is just a rough example. The number of tasks can be many based on different use-cases of different people. But I think having a basic and extensible DSL can turn out to be very useful for people who will be looking for some simple needs compared to complex needs to address which tools like Capistrano exists.
Also as said before it is the only one most popular in Ruby eco-system so if it has any limitations then also people will have no choice to choose that.
Please share your thoughts on this and if anybody is already using dry-rb for such use-cases then please guide me on the approach I should take in my case. And if it is a fresh idea I have shared, then please recommend which of the dry-rb gems can be considered potential candidates for such needs.
Thanks.