Monday, August 14, 2017

Heroku and mLab

Deployment Steps For Heroku & mLab
   

  1. Signup for Heroku
  2. Signup for mLab
  3. Create DB notable in mLab
  4. Add user in mLab
  5. Update DB url in node server
mongodb://<dbuser>:<dbpassword>@ds149122.mlab.com:49122/notable
     6. Test notable app



8. Add (specify version of node) to package.json

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

9. Add Procfile to root
web: node server.js

10. Edit  /client from notes_routes.js to app.get('/',function(req, res) {

11. Make Common Base URL on script1.js and script2.js

var getUrl = window.location;
var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];
console.log(baseUrl);

Add baseUrl instead of http://localhost:8000for all 4 CRUD methods.


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

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

10. Build and run locally
npm install
heroku local web
12. Deploy your application to Heroku
git add .
git commit -m "first commit"
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

HTML introduction

HTML stands for Hyper Text Markup Language. HTML describes the structure of web page using markup. HTML elements are the building blo...