Skip to content

Instantly share code, notes, and snippets.

@francirp
Created May 4, 2015 20:39
Show Gist options
  • Save francirp/cfa64f980f0648d6e64e to your computer and use it in GitHub Desktop.
Save francirp/cfa64f980f0648d6e64e to your computer and use it in GitHub Desktop.
Pushing Locomotive Engine to Heroku
heroku create <YOUR APP NAME>
heroku config:add BUNDLE_WITHOUT=development:test

In locomotive.rb, add the following:

config.hosting = {
  :target     => :heroku,
  :api_key    => ENV['HEROKU_API_KEY'],
  :app_name   => ENV['HEROKU_APP_NAME']
}

Change carrierwave.rb to look like:

CarrierWave.configure do |config|

  config.cache_dir = File.join(Rails.root, 'tmp', 'uploads')

  config.storage          = :fog
  config.fog_credentials  = {
    provider:                 'AWS',
    aws_access_key_id:        ENV['S3_KEY_ID'],
    aws_secret_access_key:    ENV['S3_SECRET_KEY'],
    region:                   ENV['S3_BUCKET_REGION']
  }
  config.fog_directory    = ENV['S3_BUCKET']


end

Setup Remote MongoDB

heroku addons:add mongohq

Enable Emails and AWS

In config/application.yml:

EMAIL_USERNAME:
EMAIL_PASSWORD:
S3_KEY_ID:
S3_SECRET_KEY:
S3_BUCKET_REGION: us-east-1
development:
  APPLICATION_ROOT_URL: acme-cms.dev
  S3_BUCKET:
staging:
  APPLICATION_ROOT_URL:
  HEROKU_API_KEY:
  HEROKU_APP_NAME:
  S3_BUCKET:
production:
  APPLICATION_ROOT_URL: acme-cms.herokuapp.com
  HEROKU_API_KEY:
  HEROKU_APP_NAME:
  S3_BUCKET:

In application.rb, add the following:

    config.action_mailer.delivery_method = :smtp
    config.action_mailer.default_url_options = { :host => ENV['APPLICATION_ROOT_URL'] }
    config.action_mailer.perform_deliveries = true

    config.action_mailer.smtp_settings = {
      address: "smtp.mandrillapp.com",
      port: 587,
      domain: ENV['APPLICATION_ROOT_URL'],
      authentication: "plain",
      enable_starttls_auto: true,
      user_name: ENV['EMAIL_USERNAME'],
      password: ENV['EMAIL_PASSWORD']
    }
  end

Finally, Push To Heroku

figaro heroku:set -e production
git add -A
git commit -m "first commit"
git push heroku master
heroku open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment