Scott's Recipes Logo

How to Deploy a Rails App with HatchBox Classic in Late 2022

How to Deploy a Rails App with HatchBox Classic in Late 2022

This blog post describes how to deploy a Rails app using HatchBox Classic in Late 2022. HatchBox is a Rails deployment tool from Chris of GoRails fame. HatchBox Classic is the first version of HatchBox that has been superceded by revision 2. Unfortunately Chris made the decision to have zero migration support from HatchBox Classic to HatchBox v2. Additionally he appears to have made the decision to stop fixing bugs in HatchBox Classic.

Hopefully this document is useful for people stuck in HatchBox Classic – I certainly can’t be the only one.

Criteria

For this tutorial, I was using:

Other configurations will, of course, work but those were my defaults.

Step 1: Get Your Application Onto Github

This is pretty well understood:

  1. Do a git init to create the repo.
  2. Do a git add . to add all files.
  3. Do an initial commit - git commit -m “Initial commit”.
  4. Goto github.com and create your repo.
  5. Add your origin.
  6. Do a git push to the origin. 
## Step 2: Create Your HatchBox App

  7. Go to https://classic.hatchbox.io/apps and select Create a New App.
  8. Choose your hardware cluster.
  9. Select Github as your repository host.
  10. Name your application.
  11. Set your repo as username/reponame (no .git extension)
  12. Set your main or master branch (or whatever).
  13. Select your database; this tends to be postgres.
  14. Click on environment variables and select Add ENV variable.
  15. Add RAILS_MASTER_KEY as the name.
  16. In your terminal, run the command: cat config/credentials/production.key and then copy the value to your clipboard (make sure you don’t get the trailing % sign if it is shown there).
  17. Paste that value into the value field.
  18. Click Create App and wait for the initial pre-deploy to happen. This is the process of the application being setup on your hardware.

Here are the steps I saw that indicated completion:

Step 3: Do the Initial Deploy

After your app is created and the pre-deploy happens, you need to click the Deploy button at the top. This actually deploys your app.

Step 4: Setup Push Based Deploy

  1. Click on the Deploy menu item.
  2. Click on the Enable Automatic Deploys button.

Step 5: Set a Domain

  1. Click the Configuration menu.
  2. Select Domains.
  3. Click Add Domain.
  4. Add the canonical domain version i.e. without the www.
  5. Add the www version.
  6. Click the Save Changes button.

Note: You will need to both register a domain and set its A records for the canonical and www version of the domain to match your Hatchbox account.

Step 6: Setup SSL Support

  1. Click the Configuration menu.
  2. Select SSL.
  3. Choose Let’s Encrypt.
  4. Click the Save Changes button.