infrastructure

How to take a deep dive into dockerizing your Rails app

In: infrastructure

It's 2023. Cars are flying fuelled by water, tourists visiting outer space, and I'm still not sure how to best deploy my personal project apps.

Heroku got somewhat lame. Other managed platforms are not the same as Heroku was before. I'm too lazy to self-host and self-maintain...

At the same time, I collaborate with people in some of my projects who are just waiting to crush my dreams of moving fast with Ruby on Rails. With their funny Ubuntu setup for example. Or Windows.

Docker could help unify the setup. Wrapping everything in some bin/do commands could make the setup a breeze.

⚠️
This is not your typical walkthrough number 1559 on how to try to dockerize your app. It's more about what I and some friends used so far to try to dockerize their app, what open questions there are and how you can create your own picture about it. Here I try to teach how to learn doing it and making your own judgement calls, instead of exactly how to do it.

Depending on where you are on the journey, you have a couple of options. I'm not yet seeing the best way to dockerize a Rails app, so you will need to make the judging call yourself. For now, I'll provide you with ideas and resources.

Disclaimer for Rails beginners

As a total beginner, you might benefit from not dockerizing your app at all. It has a learning curve and you might not benefit much from it as long as you don't have to jump a lot between different projects and OS setups or don't have a project where a lot of developers jump into it needing a quick setup.

If you still would like to dig into it, start with the fundamentals and learn about Docker itself, then go into the Rails-specific details. Some of the below resources might help.

Ways to put your Rails app into Docker

There are millions.

If you are a seasoned developer and infrastructure friend: I found it useful to read through a couple of blog posts and book sections. Then read their relevant files, approximately in that order:

  • Dockerfile
  • docker-compose.yml
  • bin/ folder

While I was digging the resources below, I also installed Docker and started to play around with some of them.

This way I got a pretty nice overview of the dockerizing Rails apps with that approach.

Problems

Common problems you'll often encounter with dockerizing:

  • non-automated docker files generation (leading to inconsistencies in the setup)
  • not addressing common gems that need installing
  • needing another type of dependency, like you need an extra Ruby gem on your local to manage the docker service (see first article in resources)

Resources

These are resources that I've read through, that order will give you the basics, and by arriving at the latter resources you will already have a good basis:

One other resource that looks promising but I haven't tried yet that shows it all in a container:


There are also books written about it:

However, I don't know anything about them yet. Let me know if you do :))


In the end, the approaches I liked the most were:

They worked well for a dummy project but I have yet to try them in a production-like environment, but they make a good first impression because they are:

  • fairly automated
  • enough for running a functional Rails app
  • does not need any dependencies on your operating system other than Docker

📚
Happy learning and understanding how all of this works!
Comments
More from RichStone Input Output
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to RichStone Input Output.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.