blob: 1f72cf39493513805171931c5fe23977bc874568 [file] [log] [blame]
<!--
/***************************************************************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
***************************************************************************************************************************/
-->
{8.0.0-new}
Deploying to Heroku
<p>
<a href='https://www.heroku.com'>Heroku</a> is a platform-as-a-service that allows applications to be quickly hosted
in the cloud.
The <l>juneau-examples-rest-springboot</l> project contains additional metadata files for quickly
deploying and running the examples in Heroku using free services.
</p>
<ul class='spaced-list'>
<li>
<l>app.json</l>
<br><br>
This class provides basic metadata information to Heroku about our application.
<br><br>
<p class='bcode w800'>
{
<jok>"name"</jok>: <jov>"Start on Heroku: Juneau REST Examples"</jov>,
<jok>"description"</jok>: <jov>"Deployable REST examples to Heroku."</jov>
}
</p>
<li>
<l>Procfile</l>
<br><br>
This class tells Heroku how to deploy our application using the Web dyno.
<br><br>
<p class='bcode w800'>
web: java -jar target/juneau-examples-rest-springboot-8.0.0-SNAPSHOT.jar
</p>
<li>
<l>settings.xml</l>
<br><br>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.
</ul>
<p>
You'll need to sign up for an account on Heroku.
Afterwards, you can go to the apps page to create a new application:
</p>
<p class='bpcode w1000'>
https://dashboard.heroku.com/apps
</p>
<img class='bordered w1000' src='doc-files/juneau-examples-rest-springboot.Heroku.1.png'>
<p>
Click the <l>New</l> button to create a new app, give it a unique name:
</p>
<p class='bpcode w1000'>
https://dashboard.heroku.com/new-app
</p>
<img class='bordered w1000' src='doc-files/juneau-examples-rest-springboot.Heroku.2.png'>
<p>
After clicking the <l>Create app</l> button, you should see this page:
</p>
<p class='bpcode w1000'>
https://dashboard.heroku.com/apps/juneau-examples-rest/deploy/heroku-git
</p>
<img class='bordered w1000' src='doc-files/juneau-examples-rest-springboot.Heroku.3.png'>
<p>
For this example, we'll use the <l>Heroku Git</l> option for deploying our application.
Follow the instructions for installing the Heroku CLI and logging into Heroku:
</p>
<p class='bpcode w1000'>
https://dashboard.heroku.com/apps/juneau-examples-rest/deploy/heroku-git
</p>
<img class='bordered w1000' src='doc-files/juneau-examples-rest-springboot.Heroku.4.png'>
<p>
Next, run the following commands to cd into our Eclipse project and initialize it as a local git repo:
</p>
<p class='bpcode w800'>
$ cd juneau-examples-rest-springboot/
$ git init
</p>
<h5 class='figure'>Output</h5>
<p class='bpcode w800 console'>
$ cd juneau-examples-rest-springboot/
$ git init
Initialized empty Git repository in /.../juneau-examples-rest-springboot/.git/
</p>
<p>
Next, run the following command to link our project to the Heroku app:
</p>
<p class='bpcode w800'>
$ heroku git:remote -a juneau-examples-rest
</p>
<h5 class='figure'>Output</h5>
<p class='bpcode w800 console'>
$ heroku git:remote -a juneau-examples-rest
set git remote heroku to https://git.heroku.com/juneau-examples-rest.git
</p>
<p>
Next, run the following commands to add our files to the git repo and push to the Heroku master branch:
</p>
<p class='bpcode w800'>
$ git add .
$ git commit -am "Initial deploy"
$ git push heroku master
</p>
<h5 class='figure'>Output</h5>
<p class='bpcode w800 console'>
$ 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
</p>
<p>
If no errors were shown, then our application should now be live.
You can click on the <l>Open app</l> button to open the examples application in a browser:
</p>
<img class='bordered w400' src='doc-files/juneau-examples-rest-springboot.Heroku.5.png'>
<p>
If everything worked, your browser should now be loaded with our example REST app:
</p>
<p class='bpcode w1000'>
https://juneau-examples-rest.herokuapp.com
</p>
<img class='bordered w1000' src='doc-files/juneau-examples-rest-springboot.Heroku.6.png'>