Hello World
Written by Sean on October 06, 2024
Welcome to the site!
I'm starting to write again. Mostly for fun. But writing really helps to understand complex topics. If you can explain something to an audience your grasp of the subject is better.
So here's the first post on my new site!
The Tech Stack
This site is written in Ruby on Rails, version 8.0 beta!
It's a vanilla Rails application using Postgres and Tailwind CSS.
rails new seans_software --database=postgresql --css=tailwind
That command takes care of the basics. Creating the application, setting up the database adapter to use Postgres and install Tailwind CSS.
It's very vanilla. Just the way I love to use Rails.
But the exciting thing with this site is that it is deployed using Kamal, a Rails default as of version 8.
gem install kamal
Kamal is a tool written by the great people at 37Signals and Basecamp.
It is a zero downtime deploy tool that uses Docker to run your applications. The tool is in service to 37Signal's new mission, which is to free developers from the grips of PaaS companies.
With Kamal you can deploy to any server, with almost no configuration. You do need to configure some details in your deployment, such as domain names, ip addresses, accessory services, etc. But you don't need to install anything on the server directly.
You tell Kamal what you want, it setups the server by installing Docker, networks everything together and runs your application.
Some of the concepts are a little confusing at first. It's very similar to docker-compose.yml, but not quite.
I just bought Kamal Handbook, The Missing Manual by Joseph Strzibny to help me understand it a little bit better.
I use Docker at work and I have deployed a few sites with Kamal already. However, there is still a lot I don't know about both these technologies. Looking forward to diving into the details with that book!
What Does Kamal Look Like?
All in all, it's about 50 lines of YAML to deploy to a server.
You will need a container registry, either Docker Hub or Github Container Registry will do.
You will need a server and optionally a domain name if you want https.
And that's about it. Here is the entire deploy config for this site.
service: seans_software image: sean/software servers: web: - seans.software proxy: ssl: true host: seans.software registry: username: sean password: - KAMAL_REGISTRY_PASSWORD env: secret: - RAILS_MASTER_KEY aliases: console: app exec --interactive --reuse "bin/rails console" shell: app exec --interactive --reuse "bash" logs: app logs -f dbc: app exec --interactive --reuse "bin/rails dbconsole" volumes: - "seans_software_storage:/rails/storage" asset_path: /rails/public/assets builder: arch: amd64 accessories: db: image: postgres:16 roles: - web port: "127.0.0.1:5432:5432" env: clear: DB_HOST: '%' POSTGRES_USER: mypguser secret: - POSTGRES_PASSWORD files: - config/init.sql:/docker-entrypoint-initdb.d/setup.sql directories: - data:/var/lib/postgresql/data
Just Like the Old Days!
Kamal is very exciting for me. It feels like the old days of Heroku again.
To deploy your site you just run
To deploy your site you just run
kamal setup # you just do this once, to provision everything on the server kamal deploy
But to be fair, the first time you use it, you'll likely encounter failures. Usually it's env vars not being present or you used the wrong name for the network.
So not quite as simple as Heroku from the perspective of a first time user. However, once you become more competent, it is. And you will have more freedom in terms of capability and cost will be in your control. No need to pony up, every time you need another add on.
Kamal is for Everyone
And Kamal is not just a Rails specific tool. Any application that is dockerized, can be deployed using it.
Django, Laravel, vanilla PHP. It will all work. Which is really cool because Kamal can be added to your tool belt and leveraged regardless of the underlying technology.
Very very cool stuff.