Terraform and Kamal for Digital Ocean Demo Repositories

Boon aka Hwee-Boon Yar October 31, 2024
Source
Update, May 21, 2026: I now use Terraform + Kamal 2 on Hetzner for my main products and most older projects. A few projects are still exceptions, but Hetzner + Kamal is my default now. I typically run my projects on Render. Simple, no fuss, mostly works great. I needed to run ffmpeg for a project I was researching into. This led me down a rabbit hole of self-hosted servers and inevitably, to Hetzner and Kamal. Or rather, Kamal 2. I heard the buzz recently and watched dhh's video about Kamal 2. They explicitly had support for running multiple projects on a single server [^1]. Now I used to manage my own servers, with Ansible and Capistrano. But that was many years ago. So I looked around to see what would be suitable now and save me time. After some digging, I found this repo by Dylan Castillo that uses Terraform to provision a Hetzner server. Great stuff, and exactly what I needed. I adapted it to match my needs and set up an existing project of mine to use Kamal for deployment to kick the tires. Only one problem: I had 2 web servers — a frontend running Vue and a backend running Node.js/bun. The video (and Rails typically) only use 1 web server. Then there's Hetzner's reliability — I read about multiple accounts of them apparently randomly blocking accounts. Who knows why. Might be legit, but I don't want to waste time on such drama. So I turned to Digital Ocean. I used them a few years ago. Just took a couple of emails and some ID verification to get my login working again (+1 for their timely support!). Digital Ocean is pricier, but at my modest needs, the cost bump is negligible. A few more days and more trial-and-errors later, I finally had a working setup. HERE'S WHAT I ENDED UP WITH, AND MAYBE IT'LL SAVE SOMEONE ELSE A HEADACHE OR TWO: A. Digital Ocean Terraform Demo — this repo provisions a single server on Digital Ocean. You can modify a parameter to provision a beefy server for those "throw everything on one box" scenarios. B. Kamal Frontend/Backend Demo — this repo is an example of a node.js/bun stack frontend, backend, database stack — all on one server. Deploys with Kamal 2. [^1]: Potentially adding more for redundancy, but I'll try to keep them stateless to keep things simpler

Discussion in the ATmosphere

Loading comments...