proper workflow for deploying node app
I have been learning Node for the last couple of months, and now have a complex application. My problem is that, i’d like to make it reusable, and as I was a complete noob, I haven’t thought of this from the start.
What I have :
A complex node/express app running as a daemon with pm2.
lots of child processes scripts, some in Node, and some using casperjs/phantomjs
a config file for db credentials, server port, etc.
many npm dependencies, some for the app itself, some used only by child processes.
The app itself is running perfectly, every path is stored in the config file, so deployment shouldn’t be too hard.
- All the npm dependencies in the package.json file
What I’d like to do :
- Store the app on a GIT repo so I can set it up quickly on an EC2 instance.
- Install pm2, phantomjs/casperjs, all the node_modules and create the arborescence of the app (includes some empty folders for app-created files) in a simple manner, so people who don’t have my knowledge of the app can get it up and running fast.
My question :
Do I need to add the node_modules to my git repo?
how can I integrate app deployement, install of dependencies and install of pm2, phantom and casper in the simplest possible way? I don’t mind making a script but I don’t really know where to start or best practices. Most of what I see on the web is about nodejitsu/heroku and does not apply.
My flaws :
- New to Git
- Haven’t followed any guidelines for development as it all started as a toy project.
Hope my problem is understandable, Thanks all!
SO far I have :
- Read Git for beginners: The definitive practical guide
- Made a repo on github, cloned it and used npm install to get my app dependencies.
Still trying to figure out how to include the external dependencies.
2 Solutions collect form web for “proper workflow for deploying node app”
One way to deploy would be to add a install list of commands:
- clone repository
- install dependencies
apt-get install npm ...
- install node global modules
npm install -g pm2
- install node dependencies
config.jsonand change it to your needs
- start app
The node_modules folder should not be added to the git repo. You should add all your projects node dependencies to the package.json file and
npm install /
npm update should do the rest.
You could use Capistrano for doing all the deploy tasks easily. It’s written in Ruby, but you could use it to deploying whatever you want, including Node.js apps.
You can find a lot of examples and integration modules.