From e92ca9c7835a31305b063f0548555b5ef608b042 Mon Sep 17 00:00:00 2001 From: Scott M Stark Date: Fri, 6 Dec 2024 18:53:38 -0600 Subject: [PATCH] Bring the deploying-to-heroku guide up to date Fixes #44857 --- .../main/asciidoc/deploying-to-heroku.adoc | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/docs/src/main/asciidoc/deploying-to-heroku.adoc b/docs/src/main/asciidoc/deploying-to-heroku.adoc index 8d50e5cb493a3b..69cb0d0baf2c5e 100644 --- a/docs/src/main/asciidoc/deploying-to-heroku.adoc +++ b/docs/src/main/asciidoc/deploying-to-heroku.adoc @@ -17,8 +17,8 @@ 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 @@ -26,7 +26,7 @@ This guide covers: :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 @@ -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. @@ -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= +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. @@ -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] @@ -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 ----