Quick application deployment with Heroku

My Linh Tran
3 min readFeb 2, 2021
Photo by Aron Visuals on Unsplash

So you are a beginner, maybe self-taught like myself, after having loaded your brain with tons of new concepts and theories, you’ve decided that it’s time to start your own project, something that you can actually see and feel (you know what I mean). You’ve found some short courses or quick tutorials that show you how to create your first application. You can finally make something that is different from reversing a string or traversing a tree, something… real. You now can run your application on a local machine and see what’s actually like. But after that, you’re getting more ambitious. You’re asking yourself: “How do I make my application accessible from the internet?”

Now that is the key focus of this blog.

For those who have just started to learn to program and are making their first application, Heroku is one of the best Platforms as a Service (PaaS) to build and operate applications on the cloud, meaning you're making your application run somewhere else other than on your computer. It has been around for more than 10 years and is gaining more attention among developers. It is a quick and time-efficient solution to deploy your application ready for production.

What good about Heroku for beginners like me is that it offers you a hobby plan which is free and perfect for personal or proof of concept projects. You can have up to 5 applications per account. Heroku also supports a variety of popular programming languages including Ruby, Java, PHP, Python, Node or Go… It has Git integrated as well, so you can simply deploy your app from the command line.

The platform is developed based on the concept of containerization, meaning it uses the container model to run and scale Heroku apps. I’m not going to dive into what containers are in this blog, but from my understanding, a container is like a toolbox that has everything you need to build a house. You don’t need any foreign aids in order to build a complete functional house apart from that toolbox. In that box, you’ll have all the necessary materials and detailed instructions for building that house.

In this sense, a container is …

A standard package of software—known as a container—bundles an application’s code together with the related configuration files and libraries, and with the dependencies required for the app to run.

Source: azure.microsoft.com

A container in Heroku is called a dyno.

Dynos are isolated, virtualized Linux containers that are designed to execute code based on a user-specified command.

Source: heroku.com

Heroku offers a variety of types of dynos, but for now, let’s go with the most basic one.

So what will you need to deploy an application to Heroku?

Once you’ve had your Heroku account created and CLI downloaded, from the terminal, log in to your Heroku account and follow the instruction. You can also log in from the UI on the official page.

$ heroku login

Once logged in, from the root directory of your application, initiate a local git repository.

$ git init
$ git add .
$ git commit -m "first commit"

Next, create a remote Heroku app. This will create a remote Heroku repository in your local git repository. You will then receive a URL to your application hosted on Heroku.

$ heroku create

Now, you can deploy your app to Heroku.

$ git push heroku master

Once the application is deployed, you can open your app using the following command.

$ heroku open

To check the logs for the application.

$ heroku logs --tail

And that’s it. Just a few steps and you already have an application deployed and running in production.

Enjoy your application and happy coding!

--

--