How to deploy any backend to Heroku (easily🔥) ?
Tags: go, deploy, git, heroku
Published: 2022-06-12 15:19:11

## Introduction
For the purpose of demonstration and to keep things simple we will use this [Repository](https://github.com/rahul-yr/learn-go-simple-todo-crud) **developed in Go**. But you are free to choose **any language** of your choice.

Sample Repo for Python([Url Shortener App](https://github.com/rahul-yr/learn-fastapi-simple-url-shortner)) and you can find the respective implementation [tutorial here](https://dev.to/rahulyr/simple-url-shortener-app-in-python-for-beginners-fastapi-demo-52g1)

This is a very simple [Todo crud](https://github.com/rahul-yr/learn-go-simple-todo-crud) application which you can find on the internet. Feel free to use this repo. You can even take a step further and contribute to this open source repository with additional features. 

You can find the API specs and postman collection of this repo [here](https://blog.rahuldev.in/simple-todo-app-in-go-for-beginners-demo)

To follow along with this tutorial you need to have a Heroku Account. I am gonna use GitHub as a Cloud repository. You can use any of your favorites(Bit bucket, Azure DevOps, Google cloud Repo, etc.).

> Just a quick recap for those who don't know about Heroku 

## What is Heroku?
> Heroku is a container-based cloud Platform as a Service (PaaS). Developers use Heroku to deploy, manage, and scale modern apps. Our platform is elegant, flexible, and easy to use, offering developers the simplest path to getting their apps to market.([Official read more](https://www.heroku.com/about))

## Prerequisites 
- Download and Install VS code from [here](https://code.visualstudio.com/)
- Download and install git from [here](https://git-scm.com/)
- Open your terminal and type these commands with respective details to configure git.

```
git config --global user.name "example name"
git config --global user.email "example@github.com"
``` 

- Download and install Heroku CLI from [here](https://devcenter.heroku.com/articles/heroku-cli#install-the-heroku-cli)

## Deploy
- Open your terminal and clone this [repo](https://github.com/rahul-yr/learn-go-simple-todo-crud) using the below command.

```
git clone https://github.com/rahul-yr/learn-go-simple-todo-crud.git
``` 

![clone-repo.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/joieoz62v2cb9khy8bna.PNG)

- Open the cloned repo in VS code
- It's really important to tell Heroku what steps to follow during application startup. This is where `Procfile` comes handy. You can create and mention all the steps in `Procfile` specific to your requirement ([Click here to read more on Procfile](https://devcenter.heroku.com/articles/procfile)). 

- For this scenario use this snippet in Procfile

```
web: some-app-name
``` 

![procfile-raw.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c39wtei8hqjcdxb1uj33.PNG)

- Use `heroku login` command to add the heroku session to your user account. Once it's done you will get something like this.


![heroku-login-raw.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1wou88rz7opo1ajhx5r.PNG)

- It's finally time to create an app in Heroku using the below command.

```
heroku create some-app-name
``` 

![heroku-create.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5hhbf7vhae3i3si466g.PNG)

- Now deploy your app to Heroku using below command

```
git push heroku your-branch-name:master
``` 

![heroku-deploy-1.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2v37il3dyjszb36xkl1j.PNG)

- If you get the same status as below then you have successfully 🔥 deployed to Heroku.

![heroku-deploy-2.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b41k2y0zk5u8o7fswuau.PNG)

- Use `heroku open` command to view the deployed version of your app.

## Summary
Awesome 🔥, you have successfully completed this tutorial. I would 💝 to hear your feedback and comments on the great things you're gonna build with this. If you are struck somewhere feel free to comment. I am always available.

Please find the complete code at [github](https://github.com/rahul-yr/learn-go-simple-todo-crud)