Ruby on Rails
How to deploy Ruby on Rails apps with Hatchbox
Updated
Build Steps
When Hatchbox detects rails in the Gemfile in the repository, it will trigger the Rails build process.
- Install the Ruby version from
.ruby-version,.tool-versions, orGemfile.lock - Install the correct Bundler version and dependencies
- Check for assets:precompile and run it (API-only apps won't have this)
- Check for db:migrate and run it on the
cronserver (so it only runs once a deploy)
After building, Hatchbox will add a process for the Rails server on the first deploy. Hatchbox will also add processes for Sidekiq and Solid Queue if detected as well on the first deploy.
Multiple Database Support
Rails ships with the Solid gems by default: solid_queue, solid_cache, and solid_cable. For production, your Rails application needs a database configured for each.
Assign a database for each using the matching environment variable name:
DATABASE_URLQUEUE_DATABASE_URLCACHE_DATABASE_URLCABLE_DATABASE_URL
Processes
On your first deploy, Hatchbox will detect Rails and add a process with the following command.
bin/rails server -b 127.0.0.1 -p $PORT
If Solid Queue is detected, another process will be added.
bin/jobs
If Sidekiq is detected, another process will be added.
bundle exec sidekiq