The following animation was created to present the basics of blockchain concept including how it is immutable and decentralized.
In this blog post, we will be deploying a sample JSP project in Heroku - a cloud platform as a service (PaaS) that lets companies build, deliver, monitor, and scale app. Special thanks goes to Chanaka Lakmal for the technical support provided.
Although not necessary for using Webapp Runner it’s a good idea to have your build tool download Webapp Runner for you since your application will need it to run. When you build and deploy the project locally, the webapp-runner.jar will be downloaded to target/dependency. You can specify it in the pom.xml file as follows:
In Heroku, I created an application which will be my target application. All the configurations regarding deployment of the application are under the tab Deploy.
Heroku offers multiple deployment methods that include Heroku Git, which can be defined as a more customized version of deploying through Github, but for this project, I chose the default Git deployment method as follows.
Since I had already added projects using Git before, my git account was already added and all I had to do was to search for the repository name and connect it to the application. If it is your first time connecting Git with Heroku, it will prompt you to log in.
You can add a BuildPack from the option under Settings tab.
Since my application is JSP I chose Java as the BuildPack.
Once deployed, click on Resources tab and you will see the content of your Procfile there. In order to scale our application, we must enable its dyno as follows:
That's it and we successfully deployed a JSP project in Heroku.
Updating the pom file
For Java projects, Heroku requires a pom.xml file which is used to retrieve any data regarding the deployment of the project. Therefore I created a sample JSP project with maven.Although not necessary for using Webapp Runner it’s a good idea to have your build tool download Webapp Runner for you since your application will need it to run. When you build and deploy the project locally, the webapp-runner.jar will be downloaded to target/dependency. You can specify it in the pom.xml file as follows:
<build> ... <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.3</version> <executions> <execution> <phase>package</phase> <goals><goal>copy</goal></goals> <configuration> <artifactItems> <artifactItem> <groupId>com.github.jsimone</groupId> <artifactId>webapp-runner</artifactId> <version>8.0.30.2</version> <destFileName>webapp-runner.jar</destFileName> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins> </build>
Adding the Procfile
A Procfile is a mechanism for declaring what commands are run by your application’s dynos on the Heroku platform. It is simply a text file named "Procfile" in the root of your project directory. (Note it must be named exactly as Procfile only. Names such as Procfile.txt are not allowed). In the procfile, add the following single line.web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
Adding Git connectivity
Heroku allows projects to be synced with Git therefore I initialized a Git repository too.In Heroku, I created an application which will be my target application. All the configurations regarding deployment of the application are under the tab Deploy.
Heroku offers multiple deployment methods that include Heroku Git, which can be defined as a more customized version of deploying through Github, but for this project, I chose the default Git deployment method as follows.
Since I had already added projects using Git before, my git account was already added and all I had to do was to search for the repository name and connect it to the application. If it is your first time connecting Git with Heroku, it will prompt you to log in.
Enabling automatic deployment
Once the repository is connected, Heroku will display some additional settings that allow automatic or manual deployment methods. In the Automatic Deploy, your project will be automatically updated with every Git push you perform on your repository.Adding a buildpack for the application
Next, we will add a build pack for our application. Buildpacks are scripts that are run when your app is deployed. They are used to install dependencies for your app and configure your environment.You can add a BuildPack from the option under Settings tab.
Since my application is JSP I chose Java as the BuildPack.
Deploying and scaling the application
Once the build pack is added, you can deploy it by clicking on the Deploy Branch under the Deploy tab. You can also try out the automatic deployment feature by pushing a change to the Git repo.Once deployed, click on Resources tab and you will see the content of your Procfile there. In order to scale our application, we must enable its dyno as follows:
That's it and we successfully deployed a JSP project in Heroku.