Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

proper workflow for deploying node app [closed]

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!

EDIT :

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.

like image 310
xShirase Avatar asked Oct 20 '22 21:10

xShirase


1 Answers

One way to deploy would be to add a install list of commands:

  1. clone repository
  2. install dependencies apt-get install npm ...
  3. install node global modules npm install -g pm2
  4. install node dependencies npm install and npm update
  5. copy config.example.json to config.json and change it to your needs
  6. start app pm2 index.js

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.

like image 196
Chris Spiegl Avatar answered Oct 27 '22 11:10

Chris Spiegl