{
"$type": "site.standard.document",
"description": "How I use Terraform and Kamal 2 to provision a VPS and deploy a frontend, backend, and database stack on one server.",
"path": "/terraform-and-kamal-for-digital-ocean-demo-repositories/",
"publishedAt": "2024-10-31T06:45:00.000Z",
"site": "at://did:plc:bryys25pc2fnagnyxqgsglhd/site.standard.publication/3mn26bjkkmh23",
"tags": [
"Web",
"Tools"
],
"textContent": "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.\n\nI 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.\n\nOr 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].\n\nNow 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.\n\nOnly 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.\n\nThen 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.\n\nSo 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.\n\nA few more days and more trial-and-errors later, I finally had a working setup.\n\nHERE'S WHAT I ENDED UP WITH, AND MAYBE IT'LL SAVE SOMEONE ELSE A HEADACHE OR TWO:\n\nA. 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.\n\nB. 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.\n\n[^1]: Potentially adding more for redundancy, but I'll try to keep them stateless to keep things simpler",
"title": "Terraform and Kamal for Digital Ocean Demo Repositories",
"updatedAt": "2026-05-23T00:00:00.000Z"
}