Install on Heroku

Here's how to set up cloud hosting with Heroku and Amazon S3.

๐Ÿ“˜

Locomotive on Heroku in two clicks

If you don't want to read all the manual procedure, click on the button below. It will deploy an instance of Locomotive on Heroku!
DeployDeploy

Install the engine locally

Create a new Ruby on Rails app:

rails new locomotiveapp --skip-bundle --skip-active-record
cd locomotiveapp

Update the Gemfile of the Rails application by adding the locomotivecms gem.

gem 'locomotivecms', '~> 3.0.0'

Run the Locomotive installation generator

bundle install
bundle exec rails generate locomotive:install --heroku
bundle install

Create the Heroku app from your app folder

๐Ÿšง

Heroku toolbelt is required

Visit https://toolbelt.heroku.com to get the installation instructions.

git init .
heroku create <YOUR APP NAME>

Setup default Heroku variables

๐Ÿ“˜

How to get your Heroku API key?

Visit this link and scroll down to the API KEY section.

heroku config:add BUNDLE_WITHOUT=development:test
heroku config:add HEROKU_API_KEY=<YOUR HEROKU API KEY>
heroku config:add HEROKU_APP_NAME=<YOUR HEROKU APP NAME>

Set up a remote Mongodb database

There are currently 2 Heroku add-ons for storing data in MongoDB:

Both are really great but since it's free, we'll take Mongolab for the rest of the installation.

heroku addons:create mongolab:sandbox

Set up emails

Locomotive needs to send emails and Heroku provides a nice way to send emails for free without configuring a whole mail server on your own. You can find more information here.

heroku addons:add sendgrid:starter

Set up Amazon S3

Heroku doesn't offer file storage that's why you need to register to Amazon S3.

Unless you modified your config/initializers/carrierwave.rb file, Carrierwave should be set up for Amazon S3 in the production environment.

heroku config:add S3_KEY_ID=<YOUR S3 KEY ID>
heroku config:add S3_SECRET_KEY=<YOUR S3 SECRET KEY>
heroku config:add S3_BUCKET=<YOUR S3 BUCKET NAME>
heroku config:add S3_BUCKET_REGION=<YOUR S3 BUCKET REGION>

Note: For S3 Bucket Region var, here is the correspondance table between your โ€˜humanโ€™ bucket region name, and itโ€™s endpoint:

RegionsLocation Constraint
US Standard *us-east-1
US West (Oregon) Regionus-east-2
US West (Northern California) Regionus-west-1
EU (Ireland) Regioneu-west-1
Asia Pacific (Singapore) Regionap-southeast-1
Asia Pacific (Tokyo) Regionap-northeast-1
South America (Sao Paulo) Regionsa-east-1

Pre-compile your assets

We suggest you to compile your assets locally so that if there is an issue with your assets, you will be able to debug it more easily.

It is very important that you disable the initialize_on_precompile option in the config/application.rb file of your application:

module YourApplication
  class Application < Rails::Application
    ...
    config.assets.initialize_on_precompile = false
    ...
  end
end

Then, in your terminal, run the following command:

bundle exec rake assets:precompile

Launch it!

In your terminal,

git add .
git commit -am "launch it"
git push heroku master

Then, visit your application

heroku open