Joy of Rails deploys to a single VPS hosted by Digital Ocean managed by Hatchbox.io.
Hatchbox is a great alternative to managing your own VPS deployment via Capistrano, Mina, or Kamal. There’s a YouTube video that serves as a great intro if you want to learn more.
I use a Github Action on the main
branch of the Joy of Rails Github repo for continuous deployment.
I have spent very little time debugging a failed Hatchbox deployment—they rarely happen and it’s always been my fault. The Hatchbox dashboard surfaces deploy logs and Rails logs that have helped me figure out the root cause.
Link to heading Customizing Hatchbox
I do though need to customize Hatchbox from time-to-time. I‘ve put together this page as a reference mostly for myself for future reference.
Sometimes I need help understanding how Hatchbox does things under-the-hood. There is an older version of Hatchbox, now called "Hatchbox Classic" that has a pretty extensive documentation site. Joy of Rails runs on the newer version of Hatchbox which doesn’t appear to have a docs site (as far as I know).
To make up the gap, they have a help desk site and have been very responsive to my questions or I‘ve otherwise been able to find what I need there.
Here is a collection of helpful articles from the new Hatchbox help site:
- To add symlinks during a deploy, you would use https://hatchbox.relationkit.io/articles/73-deploy-script-variables
- How to enable jemalloc: https://hatchbox.relationkit.io/articles/122-how-can-i-use-jemalloc-with-my-application
I’ve also opened up some tickets. I think it‘s difficult to share long-lived links to these conversations since they live behind a login or temporary token. Here are some selected screenshots to conversations I‘ve had I may need to refer back to.
To set compile-time flags for SQLite, I set an ENV variable for Bundler through the Hatchbox UI.
I use Litestream Ruby for streaming backups of the Joy of Rails SQLite databases. The Litestream Ruby gem provides a Rails engine to see the current status of the Litestream process managed by systemd on Hatchbox. I had to customize the Litestream Ruby gem to wire up the Rails engine properly with Hatchbox. This even me contributing this pull request to Litestream Ruby.
Since I know Hatchbox is a Rails app and I want to spread the joy of making Rails apps installable as Progressive Web Apps, I helped nudge making Hatchbox compatible with the new PWA features of Rails 7/8. This led to some improvements Chris Oliver contributed to Rails!
I‘d recommend giving Hatchbox a try if you like the idea of using VPS like DigitalOcean and don’t want to spend time wrestling with Kamal.
#ruby-on-rails #rails-configuration
More articles to enjoy
-
What you need to know about SQLiteA compilation of lessons about what the SQLite database engine can and cannot do, how Ruby on Rails helps you work with SQLite, and why it may, or may not, be a good choice to back your Rails 8 app
-
Mastering Custom Configuration in RailsLearn how to use "Rails config x" and add your own configuration options to your Rails app with built-in methods, ActiveSupport::OrderedOptions, and practical use cases.
-
Add your Rails app to the Home Screen - the Ultimate GuideRails 8 will support Progressive Web Apps (PWA) out-of-the-box but you have all the tools you need to make your Rails app installable today.