Production deployment to the Heroku Cloud

We need to choose a cloud provider. For this demo, we'll choose Heroku.

Though the Heroku account is free and you get free credits, you will have to provide your credit card information to use MySQL and other add-ons. You will only be charged if you exceed the free quota.

Let's deploy our application to Heroku by completing the following steps:

  1. First, you need to create an account on Heroku (https://signup.heroku.com/). It is free and you get free credits as well.  
  2. Install the Heroku CLI tool by following the instructions at https://devcenter.heroku.com/articles/heroku-cli.
  3. Verify that the Heroku CLI is installed by running heroku --version.
  4. Log in to Heroku by running heroku login. When prompted, enter your Heroku email and password.
  5. Now, run the jhipster heroku command. You will start seeing questions.
  6. Choose a name you like when asked Name to deploy as: (store). By default, it will use the application name. Try to choose a unique name since the Heroku namespace is shared.
  7. Next, you will be asked to choose a region? On which region do you want to deploy ? Choose between the US and EU, and proceed.
  8. Next, you will be asked to choose a deployment type? Which type of deployment do you want ? Choose JAR, and proceed.
  9. The generator will create the required files and you need to accept changes on the Gradle build files.

The console output will look like this:

The generated .yml files add Heroku-specific configurations for the application. The Procfile contains the specific command that will be executed on Heroku for the application. The Gradle build is also modified to include dependencies required by Heroku.

After generating the files, it will build the application and start uploading artifacts. This may take several minutes based on your network latency. Once this has been successfully completed, you should see the following screen:

Now, run the heroku open -a jhbook-online-store command to open the deployed application in a browser. That's it—you have successfully deployed your application to Heroku with a few commands.

When you update the application further, you can run the jhipster heroku command again to redeploy, or you can rebuild the package using ./gradlew -Pprod bootJar and then redeploy it using the heroku deploy:jar --jar build/libs/*.jar command.

Don't forget to commit the changes that you've made to git by executing the following command:

> git add --all
> git commit -am "add heroku configuration"

That is it—we have created and deployed a monolithic, full stack application to the cloud.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.111.85