Deployments

11 Mar 2024 - Ben

How do you deploy your projects? At work, we use Vercel, but my dream is to just have a server and be able to take my code anywhere. I have a little computer at my house I use to host some small docker applications, but nothing that I’ve created. It’s tough, connecting it to the outside world. But it’s a problem I’m working on. For now, I’m happy to pay Digital Ocean for some small servers, not even $10/month, to run some stuff.

But writing software and deploying it are two orthognal problems. If I went with something like Vercel, I would never be able to run it (easily, at least) on my computer at home whenever I figure out the best way to expose that. Enter Kamal, a tool that claims to let you “deploy web apps anywhere”, “from bare metal to cloud vms”. Which sounds great, that’s the flexibility I want! Made by the people behind Rails and Basecamp at 37 Signals, whom I’ve been looking up to since starting my web dev career 5 years ago. They have a good track record, I’ll take a look.

I made a quick Rails app; I have no experience with Rails in particular but all I really need is one route and a Stimulus controller , it took me a short morning to create. It’s not a fancy page, maybe I’ll link to it after it’s been running for a few days. Two days later, I got it to deploy! Not bad considering I never even needed to ssh into another machine! I found a couple tutorials to help me wiht my traefik config, had some problems with my rails master key, and now it’s on the web!

The one external resource Kamal relies on is a container registry. I didn’t want to sign up for a whole docker account or whatever just to push some dev images up, so I looked for another solution. I tried Github Container Registry, but I think you need to connect it to a code repo. I’ve been hosting my code on sourcehut, and trying to minimize my reliance on GitHub as well, so I continued to look. I settled on Digital Ocean’s container registry; added that to my config/deploy.yml file and watched kamal deploy push it up! It felt almost magical.

Kamal has a wealth of other commands to look at logs and run commands. It makes me feel like I have my own personal command center, capable of commanding all the servers I want with one command. Able to pull statuses and uptime in the blink of an eye; now I just have to decide if 512 MB is too little memory to run a rails server…