Hi All,
We have created a NodeJS + Angular2 application with Gulp as our task runner and bitbucket . We have an EC2 instance (Linux) where we are currently hosting our application. At present we are using WinSCP to transfer our code to EC2 instance. Could any one suggest how can we automate our deployment process using Gulp where in can even restart node server post deployment. We are using Jenkins which is a shared instance does not have bit bucket plugin that can do deployment. Any pointer or any guide on approach that I can follow would be of great help.
Thanks Vishal Lad
Check out envoyer.io. It was designed as a service for deploying PHP projects with zero downtime, but I don't see why it wouldn't work for Node. It has built-in hooks that allow you to customize the deployment story and run scripts at any stage in the process. Check out the free Laracasts series here.
You can actually use a bash script with ssh for that. I've tried it and it's awesome. The script would look something like this:
ssh user@myserver.domain << EOF
git fetch # get the code
git checkout COMMIT # checkout the desired commit
cp ... # copy some configuration files or whatever you'd like to do
service nginx restart # restart your services or reload configurations, etc
EOF
This is overly simplified of course. I just wanted to give you a simple snippet to get started. I'm assuming you do know how to ssh into a machine (and have permission for that). Well, in the end, you will endup with a simple script that just updates everything for you. As easy as:
$ run/deploy
And yes, I like to save my scripts in a run directory :p
We actually use the same exact build. We work on Virtual Boxes on our own machine, and use git to version control and make pull requests which we pull in if when we review them and see that they wont break anything. Then we have a .sh file we just ssh into the server and call that to restart the application.
However we are working on making an auto restart when we push to master. So we wont have to deploy the client all the time. So we are thinking of making a gulp interval to check every 30 seconds to see if there is a push to its branch which is master using simple-git. We haven't completed it yet but I will come back and respond with the finished code for this fixe when I am done. Should finish some time this week.
j
stuff ;)
check out fabric or ansible :) or you take a look at codeship and use their service :)