A fully-managed, scalable cloud platform, Heroku lets developers build, deploy, and manage apps. Small and big businesses alike use Heroku to test prototypes and launch critical business applications. More than 9 million apps have been created and deployed on Heroku. The platform manages more than 2 million data stores and the number is continuously rising. Some of the biggest brands, such as Macy's and Toyota Motor, trust the platform for scalable deployment of mission-critical apps.
As an enterprise or even a small team of developers, how can you use Heroku to shorten your time to market and make the app development life-cycle more efficient? Let's take a look.
The Unified Stack for Modern Data Teams
Get a personalized platform demo & 30-minute Q&A session with a Solution Engineer
With Heroku, you don't need to worry about managing servers, databases, or infrastructure anymore. Heroku handles all of that for you. The platform started off with support for Ruby on Rails, only. Today, it supports most of the popular programming languages, including Python, Java, Node, Scala, and others.
The platform also provides managed data services for popular databases including Postgres, Redis, and Apache Kafka. And Heroku's marketplace has add-ons that let you scale the capabilities of your mobile app. From monitoring tools to caching services and marketing add-ons, integrating your app with third-party tools on Heroku is straightforward.
Important Prerequisites for Heroku
Before you can start using Heroku, you need to sign up for a free account. The signup form is straightforward and takes less than a minute to fill. When you join Heroku, you get free dyno hours that you can use for running your free apps. Verified accounts get 450 dyno hours while verified accounts get 550 dyno hours, in addition to other benefits.
Next, you need to install Heroku Command Line Interface (CLI). CLI is the most efficient way to manage your apps. If you are a complete beginner to app development and aren't comfortable with a command line interface, you can use Heroku's dashboard for app management.
In order to install Heroku CLI, you first need to install Git. Once you have Git on your system, you should configure it before you start deploying apps to Heroku. Configuring Git allows you to set your user identity and set the default text editor, which is important to avoid running into unexpected errors.
To install Heroku CLI on MacOS, type the following in your command line:
brew tap heroku/brew && brew install heroku
For Windows, download the 32-bit or the 64-bit installer, according to the machine you have.
Here are other methods to install Heroku CLI on your system.
Now that you have the prerequisites, you are ready to start deploying your mobile app to Heroku.
Using Heroku with Python
Let's take a look at how to use Heroku with Python and Node.js, two of the most popular programming languages.
1) Prepare the App
First, create a local version of your app in order to set up a Git repository. You will need a Git repository to create a remote Heroku-hosted repository, where your code will go live. To create a local clone of your code, run the following commands:
$ git clone https://github.com/heroku/python-getting-started.git
$ cd python-getting-started
In this example, python-getting-started is the name of the sample code. Replace it with the exact name of your code that you want to deploy. Additionally, in the first command, heroku is the name of the parent directory where the code lives. Replace it with the name of the directory where you have saved your code.
Now that you have cloned your source code, it is time to deploy your app.
2) Create a Heroku Remote
In order to deploy your app to Heroku, you first need to create a Heroku-hosted Git remote repository. This is a version of your local Git repository that lives on other servers. From your app's root directory, run the following CLI command:
$ heroku create
This creates an empty Heroku Git repository for your app. If you have different versions of your app, such as production and staging, it is a good idea to name the Heroku Git repositories accordingly. To rename a Heroku Git repository, run the following command:
$ git remote rename [original name of repository] [new name of repository]
For our example, replace [original name of repository] with heroku and replace [new name of repository] with something that fits your project.
3) Deploy Your App
Once you have created a remote git, it is time to deploy your code. You do it with the git push command, as follows:
$ git push heroku master
You need to push the code to the master branch of your remote repository in order to see changes. If you push the changes to any other branch, the changes will not take effect.
Now, you can visit your app on the browser with the following command:
$ heroku open
4) Declare App Dependencies
To tell Heroku that it is a Python app, you need to install key files. Make a requirements.txt file that lists all the dependencies together. To install the text file, run the following command:
$ pip install - r requirements.txt
When you run this command, Heroku installs Python dependencies locally. Make sure you have Postgres installed correctly, though, for this step to function properly. Once you have declared the dependencies, you can run your app locally.
5. Adding a Database
Heroku has a large number of data stores in its marketplace. It provides managed data services for Postgres, Redis, and Apache Kafka. By default, Heroku adds a free Postgres Starter Tier database when you deploy your app.
Here is how you can upgrade to a better Postgres tier with the help of add-ons in Heroku. The process for adding other data stores to your app is the same.
Using Heroku with Node.js
The process of deploying a Node.js app to Heroku is exactly the same as outlined above. Just make sure that you have Node.js and npm installed on your machine.
The Unified Stack for Modern Data Teams
Get a personalized platform demo & 30-minute Q&A session with a Solution Engineer
Data from your apps should be integrated with the rest of your tech stack for more comprehensive business intelligence. Integrate.io comes with Heroku integration right out of the box. You can integrate your Heroku Postgres data store with other data pipelines within minutes on Integrate.io. Schedule a demo to see how Integrate.io lets you build ETL data pipelines from Heroku to your data warehouse.