Deploying to Heroku

Heroku is a platform-as-a-service that allows applications to be quickly hosted in the cloud. The juneau-examples-rest-springboot project contains additional metadata files for quickly deploying and running the examples in Heroku using free services.

- app.json
  This class provides basic metadata information to Heroku about our application.

  { "name": "Start on Heroku: Juneau REST Examples", "description": "Deployable REST examples to Heroku." }

- Procfile
  This class tells Heroku how to deploy our application using the Web dyno.

  web: java -jar target/juneau-examples-rest-springboot-8.0.0-SNAPSHOT.jar

- settings.xml
  This is an optional Maven settings file that points to both the main Maven repo in addition to the Apache snapshots repo if you happen to be using a snapshot version of Juneau.

You'll need to sign up for an account on Heroku. Afterwards, you can go to the apps page to create a new application:

https://dashboard.heroku.com/apps

Click the New button to create a new app, give it a unique name:

https://dashboard.heroku.com/new-app

After clicking the Create app button, you should see this page:

https://dashboard.heroku.com/apps/juneau-examples-rest/deploy/heroku-git

For this example, we'll use the Heroku Git option for deploying our application. Follow the instructions for installing the Heroku CLI and logging into Heroku:

https://dashboard.heroku.com/apps/juneau-examples-rest/deploy/heroku-git

Next, run the following commands to cd into our Eclipse project and initialize it as a local git repo:

$ cd juneau-examples-rest-springboot/ $ git init

##### Output

$ cd juneau-examples-rest-springboot/ $ git init Initialized empty Git repository in /.../juneau-examples-rest-springboot/.git/

Next, run the following command to link our project to the Heroku app:

$ heroku git:remote -a juneau-examples-rest

##### Output

$ heroku git:remote -a juneau-examples-rest set git remote heroku to https://git.heroku.com/juneau-examples-rest.git

Next, run the following commands to add our files to the git repo and push to the Heroku master branch:

$ git add . $ git commit -am "Initial deploy" $ git push heroku master

##### Output

$ git add . master (root-commit) 7c94cb9] Initial deploy 123 files changed, 11986 insertions(+) Counting objects: 127, done. $ git commit -am "Initial deploy" $ git push heroku master Delta compression using up to 8 threads. Compressing objects: 100% (113/113), done. Writing objects: 100% (127/127), 363.91 KiB | 21.41 MiB/s, done. ... remote: -----> Compressing... remote: Done: 85.9M remote: -----> Launching... remote: Released v3 remote: https://juneau-examples-rest.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/juneau-examples-rest.git * [new branch] master -> master

If no errors were shown, then our application should now be live. You can click on the Open app button to open the examples application in a browser:

If everything worked, your browser should now be loaded with our example REST app:

https://juneau-examples-rest.herokuapp.com