Saturday, 10 May 2014

Heroku App

 Deploy WAR project on Heroku

Pre Requisites :
  1.  A War File created for your project (Follow steps in Eclipse :=>  File -> Export -> Web -> WAR file)
  2. Heroku Account.

There are several ways to deploy app on Heroku but common methods have been discussed in this blog:

  1.  Deploy your code to Git and then push the code to Heroku (by using command> git push Heroku master).Upload everything onto a git repository so that you can easily push to Heroku repository. Use below directory structure:
    • pom.xml
    • Procfile
    • src/main/java/root - Demo.java
    • src/main/resources - mywebapp.jar
  2. Deply the code directly from Heroku toolbelt(i.e. by using Command prompt) to Heroku Web Application container
  3. Install Heroku-deploy CLI Plugin using command > heroku plugins:install https://github.com/heroku/heroku-deploy
    
    
    a.       Create a Heroku application using command> ‘heroku create’
    b.      To deply the project war use command> ‘heroku deploy:war –war <absolute path to war file> --app <app_name>’
    c.       Use ‘heroku open’ to open app in browser’

  4. Deploy the Heroku app directly from Ecplise project. Firstly you need to setup the Heroku plugin into Eclipse.


Steps for configuration of Heroku into Eclipse
a.       After opening Eclipse, Go to Help> Install new Software.
b.      Add a plugin by providing it a name as ‘Heroku’ and location as ‘https://eclipse-plugin.herokuapp.com/install’.
c.       Add this site and tick the checkbox ‘Heroku Eclipse Integration’.
d.      Click next and accept the license and finish installation after clicking ‘finish’.



API Key Setup for Heroku
a.       Open Eclipse>Preferences.
b.      Choose Heroku and enter Heroku username in Email field, Password in Password field (After succesfull login API key in API key will be populated).
c.       Click Login.
d.      You might need to generate a SSH key from same location and add it to Heroku.



To Deploy through Eclipse
a.       Right click your project, go to Team>Commit. Enter a proper commit message and add the files to the commit
b.      Right click the Project>Team>Push to Upstream. Heroku will perform the build based on type of app and deploy the app on Heroku on successful build.


No comments:

Post a Comment