Sunday, February 11, 2018

Heroku


Heroku is a cloud platform as a service (PaaS) supporting several programming languages that is used as a web application deployment model.
Heroku, one of the first cloud platforms, has been in development since June 2007, when it supported only the Ruby programming language, but now supports Java, Node.js, Scala, Clojure, Python, PHP.

For this reason, Heroku is said to be a polyglot platform as it lets the developer build, run and scale applications in a similar manner across all the languages. Heroku was acquired by Salesforce.com in 2010 for $212 million.

Install Heroku

# Run this from your terminal.
# The following will add our apt repository and install the CLI:

sudo add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./"

curl -L https://cli-assets.heroku.com/apt/release.key | sudo apt-key add -

sudo apt-get update

sudo apt-get install heroku

Check installation success by typing -> heroku --version
 
Signup for Heroku - https://www.heroku.com/ 
Signup for mLab - https://mlab.com

Add (specify version of node) to package.json

"engines": {
    "node": "6.10.1"
 }

Add Procfile to root
web: node server.js

Add .gitignore file to root
/node_modules
npm-debug.log
.DS_Store
/*.env

Change Port  on server.js
const port = process.env.PORT || 8000;

Build and run locally
npm install
heroku local web
Deploy your application to Heroku
git init
git add .
git commit -m "first commit"
git status
heroku login
Enter your Heroku credentials.
...

heroku create ukifunwork2byname

git push heroku master

Optional  (if above fails)- Add heroku git remote
heroku git:remote -a yourapp
And retry git push heroku master

heroku open

For Logging
heroku logs --tail

No comments:

Post a Comment