Friday, October 23, 2015

How to deploy an ionic app on heroku?

Deploy an ionic app on Heroku:

For deploy your project on heroku as a serving host we can do the following

steps:

1:- At first create a heroku account and install Heroku Toolbelt on your ubuntu system as  directed in following link

https://toolbelt.heroku.com/debian

2. Now initialize a git repository and commit all code to it

as following

git init



3. add heroku remote as following

heroku login

heroku create appname

it gives you back a git and heroku serve url on successful creation.


4. Now go to your terminal and reach to project root you want to deploy on

heroku install any dependencies needed to deploy for example if it a ionic app

as per my case we need to do as follows

npm install express --save

and create the following files

a app.json and write the following code

{

    "name": "app name",

    "description": "App description",

    "repository": "heroku serve url",

    "keywords": ["Keyword1", "Keyword2", "Keyword3"]

}


and a server.js and write the following code to serve node application

var express = require('express'),

    app = express();

app.use(express.static('www'));

app.set('port', process.env.PORT || 5000);

app.listen(app.get('port'), function () {

    console.log('Express server listening on port ' + app.get('port'));

});

and some other dependencies as well should be installed first.

5. Now do the following

git commit -am"comment for version"

git push heroku master

as heroku is the remote name by default created by heroku on app creation

and master is the default git branch.

Got to tour app serve url and check for it.

Thanks

No comments:

Post a Comment