- Sign up for a Heroku account
- Download the Heroku Toolbelt, which is tool to manage Heroku applications from command line
- Login to heroku and set up SSH keys
- Clone the sample app from my github account
- Build and verify that it starts up locally
- Configure the sample app as a heroku application and push it live
In the root folder of the sample application there is file name Procfile with the following content
This is needed to let Heroku know how to run the application.
On Heroku we cannot tell explicitly on which port should the application run, this depends runtime based on the $PORT environment variable. Our sample application by default runs on 8080 port when starting it up with above command (in the Heroku specific Procfile).
This can be easily changed with the server.port in the application.properties as seen below:
This way locally we can use the short command line arguments --port=9000 instead of --server.port=9000 and will also work on Heroku since
Spring can bind to capitalized synonyms for Environment properties.
After you have finished stop your deployed application and logout from Heroku
A running version can be accessed here.
Note that by default our application will use a single dyno (Heroku term for scaleable unit) and it will go to sleep after one hour of inactivity. This causes delay of a few seconds for the first request, subsequent requests will perform normally.
No comments:
Post a Comment