Wellcar, to containerize Rails
A personal project and reference to both better understand how to use Docker with Rails, and to help automate the set up of a Rails application that is developed and deployed in Docker containers.
This is very much an unstable, untested project that is for my own curiosity. As such, please look around but do not expect anything to work well, if at all, on your own Rails app.
If this project is of interest, give me a shout on Twitter.
I have published the gem to Rubygems.org, purely to make sure that the name wellcar
isn't taken by a different library.
Inspiration
wellcar
is very much a project for me to learn as I work on it.
As such, please mess around or whatever but do not expect any polish, or even anything to work.
The DIP gem by @bidendi is an inspiration for my tinkering here. Check it out if you're serious about developing and deploying Rails apps in Docker containers!
Kuby is a tool that automates Docker and Kubernetes for a Rails app. I discovered this via Ruby Weekly literally as I was going through publishing wellcar
.
Approach
I've taken a pragmatic, quick-and-dirty approach to building wellcar
.
Templating files for Dockerising
Docker files generation rather crudely relies on ERB templating.
There are pairs of .erb
and .rb
files within lib/wellcar/templates/
for each of the files that gets generated by wellcar new
and wellcar dock
.
I would prefer to have some sort of AST for the different file types to make the system more flexible. However, I don't know enough about Docker, the files I might need to manage or ASTs to try to tackle that right now. It would be a long-term goal to do this.
Running commands
Commands are also crudely executed with system()
calls.
This is a clunky approach but has helped me deep-dive into Docker and understand the command hierarchy, particularly between docker
and docker-compose
, and the workflow for deploying apps.
At some stage, it might be possible to interact with the Docker Daemon directly although it's debatable whether this is advantageous or not.