Since the gradle build pack for heroku is still in beta, it is sometimes not straight forward to use gradle with heroku. This is how I did it with gradle, dropwizard and heroku.
- Use gradle wrapper, the built in gradle in heroku is still using version 1.0-beta or something. When you use the wrapper, you decide the gradle version yourself.
- Use the gradle application plugin
- For some reason, you must have the dropwizard as a submodule in your gradle project.
- When deploying the app to heroku, you must tell the app to use the $PORT specified by heroku to listen to http traffic. You set this configuration by setting the WEBAPP_OPTS variable on heroku. This variable is used by the gradle application plugin when launching your java app. The value might vary, depending on your conf.yaml-file.
h
eroku config:set WEBAPP_OPTS-Ddw.server.applicationConnectors[0].port='$PORT'
- The Procfile must point to the shell script generated by the application plugin and the arguments for your application
web: webapp/build/install/webapp/bin/webapp server conf.yaml
- The dropwizard application itself does not need to have any special config to run on heroku. You can even connect to a mongodb hosted at mongolab without any problems.
If you want a working starting point for your application, have a look at my github project https://github.com/nilsmagnus/gradledwheroku which is "heroku-ready". Clone it, change it, make it your own and deploy to heroku.
No comments:
Post a Comment