How to deploy an application using Heroku?
What is Heroku?
Heroku is a cloud platform as a service (PaaS) supporting several programming languages. One of the first cloud platforms, Heroku has been in development since June 2007, when it supported only the Ruby programming language, but now it supports Java, Node.js, Scala, Clojure, Python, PHP, and Go. For this reason, Heroku is said to be a polyglot platform as it has features for a developer to build, run and scale applications in a similar manner across most languages. Heroku was acquired by Salesforce in 2010. All Heroku services are hosted on AWS EC2 cloud-computing platform.
Steps to deploy a model using Heroku
- Create a Heroku account by navigating to https://www.heroku.com/
2. Click on ‘New’ to create a new app
3. Enter the name of your app (This name should only contain lowercase letters, numbers, and dashes.) and choose a region (United States or Europe) and click on ‘Create app’.
4. Link the created app to your GitHub repository
5. Your GitHub repository must have a Procfile and requirements.txt file
Heroku apps include a Procfile that specifies the commands that are executed by the app’s dynos. Add a new file named Procfile in the root of your project folder. The Procfile is always a simple text file that is named Procfile exactly. For example, Procfile.txt is not valid. Procfile contains the following code
web: gunicorn app:app
In the above code, the parameter to the left of the colon is the name of the python file and the parameter to the right of the colon is the name of the Flask app
To create a requirements file navigate to the local directory where you have the project code using a command prompt and execute the following code
pip freeze > requirements.txt
6. Once your GitHub repository is ready with all the required files, deploy your branch in Heroku
Once the deployment is complete, a link will be generated in the format like https://<your app name>.herokuapp.com/ which can be used to globally access your application.
Please feel free to refer to my GitHub repository, where I have created an ML car price prediction application using Flask and have deployed it using the Heroku platform.