Ruby: Creating a Makefile for Stackhero deployment

This documentation is part of the Deploy to production guide. You can view the complete guide here: How to deploy your Ruby code to production in just a few minutes.

👋 Welcome to the Stackhero documentation!

Stackhero offers a ready-to-use Ruby cloud solution that provides a host of benefits, including:

  • Deploy your application in seconds with a simple git push.
  • Use your own domain name and benefit from the automatic configuration of HTTPS certificates for enhanced security.
  • Enjoy peace of mind with automatic backups, one-click updates, and straightforward, transparent, and predictable pricing.
  • Get optimal performance and robust security thanks to a private and dedicated VM.

Save time and simplify your life: it only takes 5 minutes to try Stackhero's Ruby cloud hosting solution!

To let Stackhero know how to run your application, you need to create a Makefile at the root of your project. This file defines the commands Stackhero will use during deployment.

If you're new to Makefiles or the make command, don't worry, the steps below will guide you through everything you need.

Create a Makefile with the following content:

run:
	rake assets:precompile
	rake db:migrate RAILS_ENV=production
	RAILS_ENV=production bundle exec puma -C config/puma.rb

Here's what happens in this Makefile:

  1. The run rule is required; Stackhero will automatically execute it during deployment. Please keep this name, as it serves as the entry point.
  2. The commands use rake and bundle, but you can adapt them as needed for your application.
  3. Make sure each command line starts with a tab character, not spaces. If you see an error like *** missing separator, double-check this formatting.

In the example above, deployment will:

  1. Precompile assets such as JavaScript and CSS into the public/assets directory.
  2. Run any required database migrations.
  3. Start the Puma server to serve your application.