Can dry-rb ecosystem be considered for implementing a simple DSL for deployment automation?

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 on Aug 02, 2024 9:30 am and new a deployment is to be done on Aug 02, 2024 12:30 am, then the DSL takes care of moving current folder code to 202408020930 folder and copying the new code to current folder. And making releases 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.

Hey. :wave:

I can partially answer your question when it comes to versioning/release note management. For this, you’d want to use the Milestoner gem which is built atop several Dry RB gems. You can also learn more here if you want a deeper dive:

Milestoner is definitely engineered to support deployments but not in the Capistrano sense. So Milestoner only provides a partial solution for what you’re asking for. That said, I’m working on additional tooling – built atop Milestoner – that would make this easier by using Docker. I bring up Docker because I see more teams moving in this direction rather than Capastrano//Tomo because a Dockerfile essentially provides the DSL you’re asking for. I realize this isn’t quite what you’re asking for but mostly planting a seed for consideration.

Anyway, I hope this helps some even if it only partially answers your question.

@jignesh You’d have to build a deployment tool yourself, as far as I know.

dry-cli and dry-files would be helpful, likely dry-inflectors, and dry-configurable helps build a DSL, but I’m not sure if it’s the kind of DSL you’d want.

I think if you start building it then you can just add libraries as you need them.