- RailsNotes Newsletter
- Posts
- The RailsNotes Newsletter 🟥 ISSUE #9
The RailsNotes Newsletter 🟥 ISSUE #9
🟥 ISSUE #9 (Deploying with Dokku, Hatchbox, Hetzner, Render)
Me deploying a new change to production and hoping for the best 😅
Welcome to The RailsNotes Newsletter — Issue #9!
This week we hit 480 subscribers! 🥳
We’ve nearly hit the big 500! Thank you all for subscribing and reading — really appreciate it! It helps me heaps if you share this newsletter — with friends, family, coworkers, random strangers on the street. As long as they’ve 1. got a pulse, and 2. love Ruby on Rails, they’re welcome here!
The main RailsNotes update for this week was the official launch of RailsNotes UI on Twitter! If you haven’t already, give the tweet a like / RT. It would me out heaps!
hey 𝕏ers, I'm ✨officially launching RailsNotes UI! ✨
No more HTML <table> layouts!🥳🥳🥳
Instead, add emails to your Ruby on Rails apps in minutes with pre-built ActionMailer templates and components 📬
Check it out 👇
— Harrison Broadbent (@hrrsnbbnt)
11:58 AM • Aug 31, 2023
This week is all about deployment 👩💻👨💻
There’s great stuff going on in the Rails deployment space! From bigger companies like fly.io adding better Dockerfile support, to smaller services like Hatchbox (which I’m using for RailsNotes UI and loving).
If you feel like living dangerously (or just like to experiment 🧑🔬), there’s also the self-hosted route using tools like Dokku. If you can stomach the no-guardrails approach, there’s something oddly satisfying about turning a bare-metal VPS into a solid host for your Rails apps. Plus you can reap massive benefits in terms of configuration, and price/performance.
We’re diving into all of this today!
Let’s go!
— ✨ FEATURED ARTICLE —
This is you at 3am, still tinkering with your Dokku setup, trying to get it ✨just right✨. And the massive servers in the background? €4/mo from Hetzner 😎
Deploying a Rails app with Dokku was genuinely one of the best things I’ve done. Why? Well, it’s not because I got to learn about SSL certificates and network proxies (although there was some of that!).
And it’s not because of how much fun I had tinkering around with my setup, configuring S3 backups, GitHub actions and post-deploy scripts (although there was a lot of that!).
The reason I’m so glad I tried Dokku? It showed me the world of hosting beyond major cloud providers (AWS, render.com, fly.io, heroku.com, etc).
Paying $50+/month in server costs for a fledgling side-project might seem reasonable… until you see the Hetzner pricing page and realise you can rent a beast of a VPS for €4.17/month!
Dokku was the gateway that led me to use Hetzner + Hatchbox for hosting RailsNotes UI. Without tinkering with Dokku, I would never have known that was even an option!
Plus…. tinkering with Dokku is heaps of fun 😎
This article is worth checking out if you’ve got a side project you’re looking to launch, or just have an afternoon free and are looking to hack away on something!
— 🌐 MORE ARTICLES —
I promise, this newsletter isn’t sponsored by Hatchbox* 😅 I just love it. Hatchbox is basically Dokku++ — you bring the server, and for $10/mo they handle the config, backups, deployments etc. (I rent a VPS from Hetzner for, you guessed it, € 4.17/mo).
I went with Hatchbox for RailsNotes UI (instead of raw Dokku) because I wanted more support and stability (with Dokku, you’re on you’re own 🙉). And being able to bring my own server instantly catapulted them over hosts like Render, Heroku etc.
Even if you never plan to use them, I think it’s worth skimming through their website, just to learn about what’s out there.
*(the links are affiliate links though, so spend big!)
Rails 7.1 is getting an official Dockerfile. You can get it now though with the dockerfile-rails
gem! Even though I don’t use Fly for hosting, I respect the work they’ve been putting into the Rails ecosystem. If you want to deploy your Rails app with Docker, you can grab their gem and use it now!
I used the dockerfile-rails
gem in my Dokku article to help deploy Rails to ARM servers, and it was super handy! It even includes handy flags for YJIT
and jemalloc
too, for the extra performance boost.
Sometimes, a typical, large-scale cloud host is the right choice. Maybe you’re running a large-scale app with specific requirements, or you don’t even want to think about devops. In that case, I think Render is a great choice, and Nick has a great intro article.
I’ve used Render to deploy apps in the past, and it’s been pretty great! Very much the new-age Heroku that I was looking for. If you’ve only ever used Heroku to deploy Rails apps, check Render out.
— ⚒️ HANDY TIP —
→ Handy pre-deployment checks for Rails 7
Here are two things I usually do locally, before pushing new production changes to my Rails apps.
If you pre-deploy to staging (or have a solid CI environment), these might be redundant, but they take 20 seconds and can’t hurt. And if you push straight to production, these might save your ass!
The first command double-checks that Zeitwerk (the Rails autoloader) can eager load your Rails app correctly. The second runs your app locally in production mode, by setting RAILS_ENV=production
, which can help catch other bugs.
# Pre-deployment checks you can run locally
# Takes 20s. Save hours of headaches 😅
# Check Zeitwerk eager loading
#
rails zeitwerk:check
# Run your local server in production mode for sanity
#
RAILS_ENV=production bin/dev