You are developing Angular and you want to deploy continues patches to the server and bug fixes all over the stack. You want an easy way to deploy to the VPS server you have without any need to run throw the cycle over and over again of build/zip/upload/unzip/npm i (to update dependencies). Well, we have a simple solution for you.
- An SSH access to the server
- composer/npm installed and functional
And that’s it, a cheap clean solution for you.
Continuous Deployment (is part of Continuous Integration, which involves Jenkins) of an Angular Project.
The Process usually goes as follows:
- You build a function/ component/ service
- ng build –prod
- Zip the dest folder
- Upload to the server via ftp
- Unzip the folder
- Product assessment.
- Build a server repository using the command on the home directory
git init --bare project.git
- Add a hook to update the site automatically
#this will update the files of src folder basically pulling the repo again
git --work-tree=/var/www/project --git-dir=/home/git/project.git checkout -f
cd /var/www/project #This is the location of the website folder
npm i #could be composer install on PHP Platform
ng build --prod # to build the project
- Add the repository as a remote on your project using the command
git remote add deploy2server firstname.lastname@example.org:project.git
Note: the git in email@example.com
is a ssh user that requires ssh password to be able to push changes. It should be able to use npm in the deployment folders.
- Stage the changes using
git add .
- Commit the changes
git commit -m "My Commit Message" -a
- Push the changes to the server
git push --set-upstream deploy2server master
- Voilà, the site is always in sync with the master branch of your server repository