I’d like to explore if there would be any interest in a dockerfile-hanami gem built on the same codebase. The basic idea would be to have a single command that can be run to build a Dockerfile and optionally a docker-compose.yml file. This gem would have no dependencies on Rails, but likely on things like Thor to parse command line arguments and to process templates. My current codebase may have incidental dependencies on active_support, and when we get there we can jointly decide if that’s OK or if that should be worked around.
The Dockerfiles produced would enable the application to be deployed pretty much anywhere, or even run on your own machine.
From a purely packaging point of view, all Rack/Postgres/Redis applications are essentially the same, the key difference being in the spelling of the command to launch the server, and how things like migrations are handled.
What I’m looking for is people with experience in the Hanami ecosystem to know what gems are common and what special configurations are worth looking for.
I’m open to whatever mode of cooperation works best - gathering requirements here, merging in pull requests, or even adding collaborators who are interested in helping maintaining this.
The thing that I would find most helpful is if somebody familiar with the hanami ecosystem could define a few concrete scenarios. If you look at dockerfile-rails/DEMO.md at main · rubys/dockerfile-rails · GitHub you will find a number of scripts that you can copy/paste to your OSX/Linux/WSL2 terminal to launch a demo. The equivalent to the first demo is fairly obvious. Perhaps the next one to focus on would be the third. Feel free to replace ActionCable with AnyCable. ActiveRecord with rom-rb. It looks like a SVG can be found here: Hanami Vector SVG Icon - SVG Repo. Writing down an equivalent scenario that I can run on my machine (ignoring the last few lines that set up and run the Dockerfile) would give me something to go on.
Then go from there to define other scenarios that are representative of hanami usage. Don’t worry about matching other scenarios on that page unless there is some significant difference as you will get the remaining scenarios for free (and conversely, Rails will get AnyCable and rom-rb for free - isn’t synergy wonderful?)
Once such scenario(s) is/are ready, the rest should fall in place quickly.
Yeah, the equivalent in Hanami is to subclass App::Command. Example:
module Docker
class Demo < App::Command
desc "A demonstration command"
def call(**)
# Implementation details go here.
end
end
end
Here are a few additional references to get you bootstrapped:
Dry CLI: This is where you can read up on how all of this works.
Hanami CLI: Sits atop Dry CLI. Within this repository, you might want to check out the commands and generators for further examples.
Hemo: This is my Hanami demonstration project built with HTMX so you can use this as a source as well. This extension of the Hanami CLI might be of interest as well.
I don’t know the direct answer to this but, in searching through both the CLI and Hanami core projects, I couldn’t find any reference to bundler_groups which is the method that defines [:plugins]. Someone in the community with more knowledge might need to chime in.
This may or may not help, but here’s how I use a special tools group through my Hemo application:
I control now everything with a Makefile and it really pays off. The problem in the question above is most likely linked to my poor knowledge of port mapping. Hopefully, I’ll resolve it soon.
According to the discussion, I think we both depend on Thor’s template feature to generate it.
I have an idea is use Rake to replace Thor and use ERB directly to generate the Dockerfile. The Rails and Hanami both support the rake and we can easily extend them to have the same command.