Skip to content

Latest commit

 

History

History
93 lines (65 loc) · 3.12 KB

appendix-c.md

File metadata and controls

93 lines (65 loc) · 3.12 KB

Appendix C: Deploy on the web

In this workshop, you developed your web service on the local machine (i.e. http://localhost/) which means that only yourself and people on the same network can eventually access your web site using your ip address.

For example, you can use http://localhost/ or http://127.0.0.1/ to access your machine web site (127.0.0.1 is the default address for your network card), and other people should use the real ip address instead (usually something like http://192.168.1.55/). Running a web site on the local machine is only required for development purprose, but you may want to make the web site available to anyone in the world. To do this you need to deploy your web site on a web server.

A very easy way to do this is to use 'heroku' which has a nice feature to a web site deploy from github.

Step 1 Sign up on heroku.com for a free account

Step 2 Create a node.js server by selecting the '+' sign on the top-right corner

Step 3 Push the 'Create App' button. You can leave the name field empty, and use the location you prefer.

Step 4 By default, heroku will show the 'Deploy' page, if not, select 'Deploy'

Step 5 Next, select 'GitHub - Connect to GitHub'

Step 6 Next, Press 'Connect to GitHub'

Step 7 Search for your repo

Step 8 When your repo was found, press the connect button

Step 8 Finally, choose the branch you want to auto-deploy (usually master), and press the 'Enable Automatic Deploys' button.

Now, heroku should show the following when you'll come back on your server dashboard.

Whenever you will push a change on github, the site will be rebuilt with the source found on your GitHub repository.

Note You can still deploy manually if you want, by pressing the 'Deploy Branch' button at the bottom of the page. This is actually needed for the first time unless you push a change on github.

Note On the 'Activity' tab, you can see when and if your site was rebuilt successfully or not.

Important: to let heroku know how to build the web site automatically, you need to provide a proper 'package.json' file where you mention the dependencies and the main server script. An example is provided below: ''' { "name": "AdnViewerBasic", "description": "A node.js server sample", "version": "1.0.0", "dependencies": { "serve-favicon": ">= 0.0.2", "express": ">= 4.12.3", "request": ">= 2.55.0" }, "files": [ "LICENSE", "README.md" ], "engines": { "node": ">= 0.10.0" }, "contributors": [ "Cyrille Fauvel cyrille@autodesk.com" ], "license": "MIT", "scripts": { "start": "node start.js" }, "repository": { "type": "git", "url": "https://github.com/Developer-Autodesk/workflow-node.js-view.and.data.api.git" } } '''

=========================
Home