Skip to content

Deploy Madloba on Heroku

Etienne Baqué edited this page Mar 22, 2015 · 1 revision

Compared to deploying Madloba on your server, the deployment on Heroku is more straight-forward. After getting your local machine set up and creating an account on Heroku, you'll have your app deployed within minutes.

However, we still need to develop image hosting on Amazon S3 when Madloba is deployed on Heroku: if you choose to go forward today with Heroku, you won't be able to allow your users to upload pictures with their ads.

Sorry for this inconvenience :(

Prerequisites and get web app on your local computer

  1. In order to be able to deploy Madloba, make sure you got the following on your local computer:

  2. If you don't have them set up globally on your local machine, install Rails and Bundler, by running the following scripts:

    gem install bundler
    gem install rails
    
  3. Create an account on Heroku, if you don't have one yet. Then install the Heroku Toolbelt onto your local machine.

  4. Clone the Madloba application from Github (from the initial master branch, or from any fork of your choice). For example:

    git clone git@github.com:etiennebaque/madloba.git
    
  5. Once cloned, cd into your local 'madloba' project:

    cd madloba
    

Deploy application to Heroku

Let's deploy the app onto your Heroku instance!

  1. From the root of your project, login to your Heroku account you created earlier. If it is the first time you login, you might be asked to generate SSH keys, and to have them uploaded onto your Heroku account. Just follow the different steps:

    heroku login
    
  2. Once the authentication is successful, run the following command, to create a new app (container) on Heroku. By doing so, the root url of your app will be created:

    heroku create
    
  3. Push Madloba to Heroku, with the following command:

    git push heroku master
    
  4. From the root of your Madloba web application, open ./lib/scripts/heroku/set_environment_variables.sh, and update the following information:

    • update the 'root_app' variable, replacing path_to_my_app by your absolute root path of your current folder (ie Madloba web application).
    • update the 'smtp_host' variable by your Heroku domain name (or your specific domain name attached to it). To know your Heroku domain name, type the following command from the root of your Madloba web application (it'll show something like 'adjective-noun-number.heroku.com'):
      heroku domains
      
    • update the other SMTP-related variables, with the values of your choice, based on the SMTP settings given by a web hosting provider or by a third-party service (Check out 'Setup SMTP on your Madloba website' wiki page for more details).
    • update your Amazon S3 settings: indicate your access key, your secret key, the region you've chosen during Amazon S3 registration, and your S3 bucket name.
    • update the 'notification_sender' variable. The value must be the e-mail address used as the sender when sending messages to users.
    • update the 'error_sender' and 'error_recipient' variables. Respectively, the values should be the e-mail addresses of the notifier and the recipient, should a technical problem occur on Madloba.
  5. After updating set_environment_variables.sh, run this script to set some environment variables on Heroku:

    sh ./lib/scripts/heroku/set_environment_variables.sh
    
  6. Migrate and initialize your database to Heroku, by running the following commands:

    heroku run rake db:migrate
    heroku run rake db:seed
    
  7. Scale your web app (default number of dynos: 1)

    heroku ps:scale web=1
    

That's it!

Congratulations! Your Madloba website is now fully deployed on Heroku.

If you're not sure what the main url of your website is, type the following command from your Madloba root folder. It will open automatically your website on your default browser:

heroku open

Enjoy!