Deploy a NodeJS app on Heroku using Redis


Profile picture for Ajeet Raina
Author:
Ajeet Raina, Sr. Technical Marketing Manager at Redis

Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud. It is a platform for data as well as apps - providing a secure, scalable database-as-a-service with tons of developers tools like database followers, forking, dataclips and automated health checks.Heroku is widely popular as it makes the processes of deploying, configuring, scaling, tuning, and managing apps as simple and straightforward as possible, so that developers can focus on what’s most important: building great apps that delight and engage customers.

Step 1. Create a Redis Enterprise Cloud Database#

Create your free Redis Enterprise Cloud account. Follow this link to create a Redis Enterprise Cloud subscription and database as shown below:

heroku

Save the database endpoint URL and password for future reference.

Step 2. Create a Heroku account#

If you are using Heroku for the first time, create your new Heroku account through this link

heroku

Step 3. Install Heroku CLI on your system#

brew install heroku

Step 4. Login to Heroku#

heroku login
heroku: Press any key to open up the browser to login or q to exit:
Opening browser to https://cli-auth.heroku.com/auth/cli/browser/XXXXXXXXXXA
Logging in... done
Logged in as your_email_address

Step 5. Connect your application to Redis Enterprise Cloud#

For this demonstration, we will be using a Sample Rate Limiting application

Clone the repository#

git clone https://github.com/redis-developer/basic-redis-rate-limiting-demo-nodejs

Run the commands below to get a functioning Git repository that contains a simple application as well as a package.json file.

heroku create
Creating app... done, ⬢ rocky-lowlands-06306
https://rocky-lowlands-06306.herokuapp.com/ | https://git.heroku.com/rocky-lowlands-06306.git

Step 6. Setting up Environmental variable#

Go to the Heroku dashboard, click "Settings" and set REDIS_ENDPOINT_URI and REDIS_PASSWORD under the Config Vars. Refer to Step 1 for the correct values to use.

heroku

You now have a functioning Git repository that contains a simple application as well as a package.json file, which is used by Node’s dependency manager.

Step 7. Deploy your code#

$ git push heroku

Wait for few seconds and you will see the messages below:

remote: -----> Launching...
remote: Released v3
remote: https://rocky-lowlands-06306.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/rocky-lowlands-06306.git
* [new branch] main -> main

Step 8. Accessing the application#

Open https://rocky-lowlands-06306.herokuapp.com/ to see your application

heroku

Next Step#