In Susper, currently we have two branches, master and development branch. The master branch is deployed on susper.com and we needed a deployment of development branch. For this we are using heroku and in this blog I will describe how we have deployed Susper’s development branch on heroku at http://susper-dev.herokuapp.com
Here are the steps:
1.Get a free heroku account:
To deploy our apps on heroku we must have a heroku account which can be created for free on https://www.heroku.com.
2.Create a new app on heroku:
After creating an account we need to create an app with a name and a region, for Susper we have used name susper-dev and region as United States.
3.Link the app to Susper’s development branch:
After successfully creating the app we need to link our app to Susper’s development branch and in Deploy section and then we have to enable automatic deployment from development branch after CI passes.
- Setup the Susper Project:
Now we have deployed our and we need to configure it so that it can successfully start on heroku. Following are the steps to configure Susper.
a) Add node and npm engine in package.json:
Now we need to tell heroku which npm and node version to use while running our app,this can be done by defining an engine field in package.json and adding npm and node versions as values as shown here:
b) Adding a postinstall field under scripts field in package.json:
Now we need to tell heroku the command that we will be using to build our app. Since on susper.com we are using ng build –prod –build-optimizer that builds our app for production by optimizing the build artifacts. Therefore on heroku also we will be using the same command:
c) Defining dependencies and typescript version for our project:This can be done by defining the @angular/cli ,@angular/compiler-cli and typescript and their version under dependencies field in package.json. In Susper we are using the following dependency versions.
Now we need to run this file, for this we will change start command in package.json file under script to start this file.
Now everytime a new commit is made to development branch our app will be automatically deployed on heroku at https://susper-dev.herokuapp.com
- Deploying the angular app to heroku https://stackoverflow.com/a/50241017/7407321
- Heroku node.js support: https://devcenter.heroku.com/articles/nodejs-support
- Deploying nodejs app on heroku: https://devcenter.heroku.com/articles/deploying-nodejs