Deploy your application to Heroku

Heroku allows you to run, manage, deploy your application written in Java, Node.js, PHP, Python, Closure, Go, Scala, Ruby and so on. Application is nothing but the source code written in any of these languages along with the set of dependency description. The dependency file varies based on the programming language such as package.json in Node.js and pom.xml in Java. Your source code along with the dependencies provides enough information to Heroku so that it can build your application.

Let’s get started with deploying your application to Heroku. Make sure you sign up for a Heroku account.

Now consider you have your application along with the source code and dependencies in GitHub repository. To deploy your code, the basic requirement is a “Deploy to Heroku button” as shown below.

To add a deploy to Heroku button first make sure you have a well formed app.json file similar to the one shown below.

Next check your README.md

This uses an explicit template where the template query parameter refers to the URL of the repository.

Now click on the Deploy to Heroku button from your GitHub repository. It will redirect you to Heroku dashboard as shown below.

The app name is optional. If left blank, it will assign a name automatically.

Click on Deploy button.

Now you have successfully deployed your application on Heroku. Let’s have a quick tour of the application.

Click on Manage App button. You can see the below tabs.

Overview: It provides a quick overview of your application.

Resources: It will give a complete information about the resources such as dynos, add-ons (Heroku Postgres, Heroku Connect)

Deploy: It will show you various deployment methods such as Heroku CLI, GitHub, Dropbox.

Metrics: Information about your application metrics.

Activity: Complete information about your application activity.

Access: The users who have access to your application such as members, collaborators, admin.

Using Heroku CLI

Once you have your Heroku CLI installed, open your command prompt and start using Heroku to deploy your applications.

Verify your Heroku CLI installation heroku –version.

heroku login : To authenticate users to your Heroku account.

heroku apps- To fetch the list of deployed Heroku apps.

heroku apps:info <your-app-name> – To get complete information about the deployed application. You can see how many dynos you have running (one dyno of a type called “web”) and the web URL by which you can access your app on the Internet.

Now let’s scale up/down the number of dynos.

heroku ps:scale web=0 –a <your-app name> – This scales down your number of dynos to zero. Similarly you can scale it to any number.

Now let’s clone the application locally on your system.

git clone <GitHub URL> <your app’s name>

cd <your app’s name>

heroku git:remote -a

The above commands will clone your application along with the dependencies on your local system and it creates a remote that references the remote repository.

Now let’s make some changes locally and push the changes back to Heroku.

So now you have deployed your first application to Heroku. You also have used the Heroku CLI along with Heroku dashboard to deploy the application. Heroku also has enormous capabilities to integrate itself with Salesforce using various methods. Our upcoming blogs will provide you a great insight into all the capabilities that Heroku provides to its users.