Ruby: Creating a Makefile for Stackhero deployment
This documentation is part of the Deploy to production guide. View the full guide here: How to deploy your Ruby code to production in 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 are new to Makefiles or the
makecommand, do not worry, the steps below will walk 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 is what is happening in this Makefile:
- The
runrule is required, Stackhero will automatically execute it during deployment. Please keep this name as it acts as the entry point. - The commands use
rakeandbundle, but you can customize them as needed for your application. - 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:
- Precompile assets like JavaScript and CSS into the
public/assetsdirectory. - Run any needed database migrations.
- Start the Puma server to serve your application.