11

Has anyone had luck deploying a JHipster application to Heroku? I think a custom buildpack is required, but I'm not 100% sure, as I'm new to Heroku.

Jeremiah Atwood
  • 153
  • 1
  • 6

4 Answers4

6

I have started an Heroku sub-generator for JHipster, using your comments:

https://github.com/jhipster/generator-jhipster/tree/master/heroku

I already have it working, I just need some tuning before it becomes official.

Concerning memory and boot timeout issues, I got both working OK.

Julien Dubois
  • 3,678
  • 1
  • 20
  • 22
  • Given an application generated using jhipster 1.0, how could I use https://github.com/jhipster/generator-jhipster/tree/master/heroku ? I tried yo jhipster:heroku but it doesn't add nothing new so I guess I forgot download or update something. – Ignasi Sep 07 '14 at 21:26
  • I have just started it, it's not released yet. You need to use the development version, from the Git repository. – Julien Dubois Sep 08 '14 at 07:55
  • Ok, so I should clone https://github.com/jhipster/generator-jhipster and compile it some way in order to replace my jhipster generator by the development version from github. Where I can find docs about how compile it? I saw system.properties with java 1.8, is needed? – Ignasi Sep 08 '14 at 09:25
5

I ran into two problems when trying to deploy to Heroku.

First problem, Heroku detects my application as Node.js since the package.json file is located in the root. Okay, easy fix as you just create a .slugignore file and ignore the package.json. Now it recognized the pom.xml and builds.

Second problem, the slug size of the default jhipster is about 340mb. The 'slug' is basically the size of all dependencies pulled in as your application builds. Max slug size allowed by Heroku is 300MB. Rather then try to sort through dependencies and strip away functionality I switched to using Amazon Elastic Beanstalk. Rather then building on Amazon's servers you deploy the compressed .war file to a Tomcat env and this works fine.

I'd be interested to know if anybody has more luck than me with Heroku, but though I'd share what I found.

Update

I successfully deployed the stock jhipster app to a t1.micro (smallest) instance on Elastic Beanstalk while connecting to a Amazon RDS PostgreSQL data source. This instance qualifies for the free tier (1 year) and gives you 1GB memory. The only config change I had to make was pump up the JVM Heap + PermGen space to 512MB and 128MB respectively. It was as easy as running "mvn package -Pprod" and then taking the app_name.war.original (the one without tomcat embedded) and deploying that to the instance Tomcat server.

Here are the JVM stats from the UI when running at pretty much no load: enter image description here

AdrieanKhisbe
  • 3,899
  • 8
  • 37
  • 45
cmikeb1
  • 1,054
  • 9
  • 19
  • I'm the JHipster lead developer : I didn't know about this .slugignore file, can you create a ticket and give us your configuration ? I would like to have an heroku sub-generator – Julien Dubois Aug 20 '14 at 19:08
  • The details on the slug are here: https://devcenter.heroku.com/articles/slug-compiler. Sounds like the best approach would be what @jbaris mentioned below where you use a custom build pack, forked from https://github.com/heroku/heroku-buildpack-java. The jhipster-heroku sub-generator may include a procfile, system.properties and .slugignore but the user would still need to create an app that specifies the custom buildpack. – cmikeb1 Aug 20 '14 at 22:10
3

The two problems that @CMikeB1 mentioned can be solved by using a custom buildpack. There is a fork that joins java and node: https://github.com/lordviktor/heroku-buildpack-java-node-yeoman-submodule. I have forked this to remove the .m2 directory and reduce de slug size https://github.com/jbaris/heroku-buildpack-java-node-yeoman-submodule.

Buuut, there are two new problems:

  1. Error R14 (Memory quota exceeded): the free account has 512 MB of RAM: this causes dynos swapping and loss performance. Consider the default JHipster app requires about 800 MB of RAM.

  2. Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch: if the app cant get up within 60 seconds of launch, its considered crashed.

Note that the first problem affects the second. My (current) conclusion: Heroku free account is not compatible with JHipster :S

I will try Amazon Elastic Beanstalk. Did you recommend another alternative?

Juan Ignacio Barisich
  • 2,061
  • 19
  • 21
  • 1
    I successfully deployed the stock jhipster app to a t1.micro (smallest) instance on Elastic Beanstalk while connecting to a Amazon RDS PostgreSQL data source. This instance qualifies for the free tier (1 year) and gives you 1GB memory. The only config change I had to make was pump up the JVM Heap + PermGen space. – cmikeb1 Aug 20 '14 at 19:57
0

I have deployed an app to Heroku sucessfully (https://smallgis.herokuapp.com/#/login), you should create an app in Heroku and install the mlab add on (mongodb in my case), you should always mantain the slug size less of 300 MB. Link your project to the heroku app that you had created.

heroku login

Create a new Git repository

Initialize a git repository in a new or existing directory

  • cd my-project/
  • git init
  • heroku git:remote -a appname

Deploy your app

  • git add .
  • git commit -m "changes...."
  • git push heroku master (It builds and compresses all the app and you could visualize in the default heroku application url)