Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Deploying Sharetribe to Heroku

Deploying to Heroku

  1. Deploy the app to heroku following heroku normal instructions (add link to heroku help)

  2. Set heroku environment variables

    Make sure all the options in config.yml are properly set then run:

     bundle exec rake heroku:config
    

    Copy, paste and run the generated command

  3. Remove postgres addon

     heroku addons:destroy heroku-postgresql
    
  4. Addons: MemCachier (free) and SSL ($20)

     heroku addon:create memcachier:dev
     heroku addons:create ssl:endpoint
    
  5. Addons: New Relic

     heroku addon:create newrelic:wayne
    

    Open the addon by running

     heroku addon:open newrelic
    

    Click on the top-right dropdown menu and select "Account Settings". On your account page, copy your License key. Open config/newrelic.yml to set license_key variable value to your license.

  6. Addon: Flying Sphinx ($55)

     heroku addons:create flying_sphinx:ceramic
    

    Ceramic plan is needed for Delta indexes. If you can manage without Delta Indexing, smaller plan is also ok

  7. Addon: MySQL

     heroku addon:create cleardb:ignite
    

    Now get your database url by running

     heroku config:get CLEARDB_DATABASE_URL
    

    Copy the value of CLEARDB_DATABASE_URL returned and CHANGE the adapter from mysql:// to mysql2:// (there's a 2 there). Then set the value of DATABASE_URL environment variable.

     heroku config:add DATABASE_URL='mysql2://{the rest of your connection string}'
    

    And initialize your database

     heroku run bundle exec rake db:schema:load
    
  8. Addon: Heroku scheduler

     heroku addon:create scheduler:standard
    

    Open the scheduler

     heroku addon:open scheduler
    

    And add the following jobs

    Job Frequency
    flying-sphinx index hourly
    rails runner "CommunityMailer.deliver_community_updates" Daily
    rake sharetribe:delete_expired_auth_tokens Daily

Recomended dyno sizes

  • web: Standard-2X
  • worker: Standard-2X
@stemado

This comment has been minimized.

Show comment Hide comment
@stemado

stemado Sep 30, 2015

Haven't had a chance to try this yet, but formal instructions on this topic were much needed.

Many thanks!

stemado commented Sep 30, 2015

Haven't had a chance to try this yet, but formal instructions on this topic were much needed.

Many thanks!

@kubido

This comment has been minimized.

Show comment Hide comment
@kubido

kubido Oct 10, 2015

just mention some typo for "heroku addon:" it should "heroku addons:" :)

kubido commented Oct 10, 2015

just mention some typo for "heroku addon:" it should "heroku addons:" :)

@taranda

This comment has been minimized.

Show comment Hide comment
@taranda

taranda Nov 8, 2015

Thanks. It took some doing, but I got this to deploy on Heroku. Thank you for the comprehensive guide. I will say that I had to remove the environment variable from the passenger max-pool-size to get this to work. If you run into deployment problems, consider changing the first line of Procfile to read:

web: bundle exec passenger start -p $PORT --max-pool-size 3

Cheers.

taranda commented Nov 8, 2015

Thanks. It took some doing, but I got this to deploy on Heroku. Thank you for the comprehensive guide. I will say that I had to remove the environment variable from the passenger max-pool-size to get this to work. If you run into deployment problems, consider changing the first line of Procfile to read:

web: bundle exec passenger start -p $PORT --max-pool-size 3

Cheers.

@piotrb

This comment has been minimized.

Show comment Hide comment
@piotrb

piotrb Nov 8, 2015

Thanks for the guide, this needs to mention setting up sphinx properly.

  1. if you're using cleardb you need to grab the certificate chain from them and configure thinking sphinx to use that chain (the default seems to be a RDS cert chain)
  2. need to initialize flying sphinx with flying-sphinx rebuild first time around

piotrb commented Nov 8, 2015

Thanks for the guide, this needs to mention setting up sphinx properly.

  1. if you're using cleardb you need to grab the certificate chain from them and configure thinking sphinx to use that chain (the default seems to be a RDS cert chain)
  2. need to initialize flying sphinx with flying-sphinx rebuild first time around
@ghost6p

This comment has been minimized.

Show comment Hide comment
@ghost6p

ghost6p Dec 15, 2015

Any idea how to get braintree working?

ghost6p commented Dec 15, 2015

Any idea how to get braintree working?

@williamrussellajb

This comment has been minimized.

Show comment Hide comment
@williamrussellajb

williamrussellajb Jan 20, 2016

How to get gmail smtp working?

How to get gmail smtp working?

@mouddai

This comment has been minimized.

Show comment Hide comment
@mouddai

mouddai Mar 16, 2016

Hi,
When I execute : bundle exec rake heroku:config I have the following message:

rake aborted!
LoadError: cannot load such file -- mysql2
/Users/Inel/.rvm/gems/ruby-2.2.4/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx.rb:6:in `require'

anyone has had the same problem ?

mouddai commented Mar 16, 2016

Hi,
When I execute : bundle exec rake heroku:config I have the following message:

rake aborted!
LoadError: cannot load such file -- mysql2
/Users/Inel/.rvm/gems/ruby-2.2.4/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx.rb:6:in `require'

anyone has had the same problem ?

@mooreds

This comment has been minimized.

Show comment Hide comment
@mooreds

mooreds Mar 29, 2016

Make sure you set up s3 too otherwise you won't be able to upload images.

mooreds commented Mar 29, 2016

Make sure you set up s3 too otherwise you won't be able to upload images.

@mooreds

This comment has been minimized.

Show comment Hide comment
@mooreds

mooreds Mar 29, 2016

And make sure you set up a CDN as outlined here: https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn#adding-cloudfront-to-rails otherwise your javascript and css assets won't be served once you set up s3.

mooreds commented Mar 29, 2016

And make sure you set up a CDN as outlined here: https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn#adding-cloudfront-to-rails otherwise your javascript and css assets won't be served once you set up s3.

@mooreds

This comment has been minimized.

Show comment Hide comment
@mooreds

mooreds Apr 3, 2016

And don't forget to update your cdn settings to allow CORS sharing, as outlined here: http://stackoverflow.com/questions/25945419/how-do-i-configure-access-control-allow-origin-with-rails-and-nginx/25977267#25977267

Otherwise your fonts will not work.

mooreds commented Apr 3, 2016

And don't forget to update your cdn settings to allow CORS sharing, as outlined here: http://stackoverflow.com/questions/25945419/how-do-i-configure-access-control-allow-origin-with-rails-and-nginx/25977267#25977267

Otherwise your fonts will not work.

@sebap

This comment has been minimized.

Show comment Hide comment
@sebap

sebap Jul 2, 2016

For sphinx this is what worked for me:
1 - Download your certificates (3 files) from ClearDB dashboard
2 - Remove password form the key file as follows:
$ openssl rsa -in cleardb_id-key.pem -out cleardb_id-key-no-password.pem
3 - Remove the -no-password from the new file and add the new file plus the other two to your repo and configure them under the prod section of your thinking_sphinx.yml
4 - deploy your changes and run
heroku run bundle exec flying-sphinx configure
heroku run bundle exec flying-sphinx rebuild
heroku run bundle exec flying-sphinx index 
heroku run bundle exec flying-sphinx start

5 - Try doing a search and you should not see the red error anymore

This is a good Q&A: http://support.flying-sphinx.com/discussions/problems/2037-no-erros-but-search-is-not-working-on-heroku

sebap commented Jul 2, 2016

For sphinx this is what worked for me:
1 - Download your certificates (3 files) from ClearDB dashboard
2 - Remove password form the key file as follows:
$ openssl rsa -in cleardb_id-key.pem -out cleardb_id-key-no-password.pem
3 - Remove the -no-password from the new file and add the new file plus the other two to your repo and configure them under the prod section of your thinking_sphinx.yml
4 - deploy your changes and run
heroku run bundle exec flying-sphinx configure
heroku run bundle exec flying-sphinx rebuild
heroku run bundle exec flying-sphinx index 
heroku run bundle exec flying-sphinx start

5 - Try doing a search and you should not see the red error anymore

This is a good Q&A: http://support.flying-sphinx.com/discussions/problems/2037-no-erros-but-search-is-not-working-on-heroku

@mooreds

This comment has been minimized.

Show comment Hide comment
@mooreds

mooreds Aug 11, 2016

If you are deploying 5.8, you need to make sure you set up the node multipack first otherwise the NPM calls will fail: https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app

mooreds commented Aug 11, 2016

If you are deploying 5.8, you need to make sure you set up the node multipack first otherwise the NPM calls will fail: https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app

@johnsonyeap

This comment has been minimized.

Show comment Hide comment
@johnsonyeap

johnsonyeap Jan 3, 2017

When there is no schema.rb in the project folder,

how will the following command works?

heroku run bundle exec rake db:schema:load

johnsonyeap commented Jan 3, 2017

When there is no schema.rb in the project folder,

how will the following command works?

heroku run bundle exec rake db:schema:load
@jarvisjohnson

This comment has been minimized.

Show comment Hide comment
@jarvisjohnson

jarvisjohnson Jan 18, 2017

@johnsonyeap - Sharetribe uses SQL - command is

heroku run bundle exec rake db:structure:load

Also, AFAIK SSL:endpoint addon is not necessary with less than 1% of browsers requiring it.

Instead, just upload your certificate to Heroku, no addon needed.

@johnsonyeap - Sharetribe uses SQL - command is

heroku run bundle exec rake db:structure:load

Also, AFAIK SSL:endpoint addon is not necessary with less than 1% of browsers requiring it.

Instead, just upload your certificate to Heroku, no addon needed.

@jarvisjohnson

This comment has been minimized.

Show comment Hide comment
@jarvisjohnson

jarvisjohnson Jan 18, 2017

I've created an updated version of these instructions if anyone needs them here

Cheers

I've created an updated version of these instructions if anyone needs them here

Cheers

@cstbr

This comment has been minimized.

Show comment Hide comment
@cstbr

cstbr Jan 23, 2017

What the mininum to deploy a serve at heroku? Like 500users? 1 dyno + ceramic + free addons?

cstbr commented Jan 23, 2017

What the mininum to deploy a serve at heroku? Like 500users? 1 dyno + ceramic + free addons?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment