Skip to content

Commit

Permalink
Bring the deploying-to-heroku guide up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
starksm64 authored and gsmet committed Dec 9, 2024
1 parent 754215b commit e92ca9c
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions docs/src/main/asciidoc/deploying-to-heroku.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ This guide covers:
* Install the Heroku CLI
* Deploy the application to Heroku
* Deploy the application as container image to Heroku
* Using Docker
* Using Podman
** Using Docker
** Using Podman
* Deploy the native application as container image to Heroku
== Prerequisites

:prerequisites-time: 1 hour for all modalities
:prerequisites-no-graalvm:
include::{includes}/prerequisites.adoc[]
* https://www.heroku.com/[A Heroku Account]. Free accounts work.
* https://www.heroku.com/[A Heroku Account]. You need at least an Eco account to deploy an application.
* https://devcenter.heroku.com/articles/heroku-cli[Heroku CLI installed]

== Introduction
Expand All @@ -48,8 +48,14 @@ Luckily, there's a dynamic configuration property for it.

This guide will take as input an application developed in the xref:getting-started.adoc[Getting Started guide].

Make sure you have the getting-started application at hand, or clone the Git repository: `git clone {quickstarts-clone-url}`,
or download an {quickstarts-archive-url}[archive]. The solution is located in the `getting-started` directory.
We need to create a new repository for the application, so follow these steps:

1. Make a clone of the Git repository: `git clone {quickstarts-clone-url}`,
or download an {quickstarts-archive-url}[archive].
2. Copy the contents of the `quarkus-quickstarts/getting-started` directory to a new directory.
3. Change to the new directory and initialize a new Git repository: `git init -b main`.
4. Add all files to the repository: `git add .`.
5. Commit the files `git commit -a -m 'Initial copy of getting-started'`.

Heroku can react on changes in your repository, run CI and redeploy your application when your code changes.
Therefore, we start with a valid repository already.
Expand Down Expand Up @@ -110,25 +116,39 @@ git add Procfile
git commit -am "Add a Procfile."
----

Your application should already be runnable via `heroku local web`.
Your application should already be runnable via `heroku local web` from the repository root directory. You need to have run `mvn package` before to create the runnable jar for this to succeed.

Let's create an application in your account and deploy that repository to it:
Now let's create an application in your account and deploy that repository to it:

[source,bash]
----
heroku create
git push heroku master
heroku open
----

The application will have a generated name and the terminal should output that. `heroku open` opens your default browser to access your new application.
This will create a remote repository in your Heroku account, and it should have also added a heroku remote url to your local repository which you can view using `git remote -v`:
[source,bash]
----
starksm@Scotts-Mac-Studio getting-started % git remote -v
heroku https://git.heroku.com/young-shelf-58876.git (fetch)
heroku https://git.heroku.com/young-shelf-58876.git (push)
----

To access the REST endpoint via curl, run:
Now you can push your application to Heroku and open it in your browser.
[source,bash]
----
git push heroku main
heroku open hello
----

The application will have a generated URL and the terminal should output that. `heroku open hello` opens your default browser to access your new application using the '/hello' context. That page should output the text 'hello'.

To access the REST endpoint via curl, get the app URL from the heroku info command:

[source,bash]
----
APP_NAME=`heroku info | grep "=== .*" |sed "s/=== //"`
curl $APP_NAME.herokuapp.com/hello
heroku info | grep "Web URL:"
APP_NAME=<https url info>
curl $APP_NAME/hello
----

Of course, you can use the Heroku CLI to connect this repo to your GitHub account, too, but this is out of scope for this guide.
Expand All @@ -137,6 +157,7 @@ Of course, you can use the Heroku CLI to connect this repo to your GitHub accoun

The advantage of pushing a whole container is that we are in complete control over its content and maybe even choose to deploy a container with a native executable running on GraalVM.


First, login to Heroku's container registry:

[source,bash]
Expand Down Expand Up @@ -183,6 +204,7 @@ With Docker installed, these steps are simple:
[source,bash]
----
docker push registry.heroku.com/$APP_NAME/web
heroku stack:set container
heroku container:release web --app $APP_NAME
----

Expand Down

0 comments on commit e92ca9c

Please sign in to comment.