Saturday 18 January 2014

Deploying local Nodejs git repo to Heroku, what to remember about?

A short summary on deploying local code using git to heroku, which requires a fair bit of googling  every time I'm attempting it. All we need to do after we've got our code working locally with all the packages we required installed.
  1. heroku create appname - creates a heroku app with a given name ( if not explicitly stated it's gonna get randomized )
  2. git remote -v - will show us whether the remote was successfully created for our local repo.
  3. create a procfile, which describes what types of processes are gonna be launched on Heroku in my case (a web server) the inside of the files were as follows:

    web: node name_of_the_node_server_file.js

  4. Create a package.json file which contains information about the app, especially the packages info, and launching script. In my case it looked like that:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    {
      "name": "AppName",
      "version": "0.0.1",  
      "description": "Description",
      "main": "name_of_the_server_file.js",
      "dependencies": {
     "connect": "x.x.x",
     "util": "x.x.x"
      },
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node name_of_the_server_file.js"
      },
      "repository": {
        "type": "git",
        "url": "https://bitbucket_login@bitbucket.org/bitbucket_login/repo_name.git"
      },
      "author": "Name"
    }
    


  5. We need to add these files and use a standard git commit
  6. git push heroku master - where heroku is a remote created by "heroku create".
  7. Now we can open our app on heroku.
  8. In case of errors we can check the logs from the server through command line:

    heroku logs 
Helpful links:

         Deploying to Heroku with git - https://devcenter.heroku.com/articles/git
         Heroku logs - https://devcenter.heroku.com/articles/logging
         Procfile types - https://devcenter.heroku.com/articles/procfile


No comments:

Post a Comment