Start Design Your Online Store

Calendar is loading...
- Available
- Booked
- Pending
Whats App

Easy and Fast Deployment to VPS using Git

Yes Soft 2
Post Image

The Problem

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.


You need: 

  • An SSH access to the server
  • composer/npm installed and functional

And that’s it, a cheap clean solution for you.

Demonstration’s Scenario

Continuous Deployment (is part of Continuous Integration, which involves Jenkins) of an Angular Project.

The Process usually goes as follows:

  1. You build a function/ component/ service
  2. ng build –prod
  3. Zip the dest folder
  4. Upload to the server via ftp
  5. Unzip the folder
  6. Product assessment.

The Trick

  1. Build a server repository using the command on the home directory
     git init --bare project.git
  2. Add a hook to update the site automatically
    unset GIT_INDEX_FILE
     #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
  3. Add the repository as a remote on your project using the command
    git remote add deploy2server

    Note: the git in 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.
  4. Stage the changes using
    git add . 
  5. Commit the changes
    git commit -m "My Commit Message" -a
  6. Push the changes to the server
    git push --set-upstream deploy2server master
  7. VoilĂ , the site is always in sync with the master branch of your server repository

Categories : Blog, Git

User Avatar
Yes Soft ( Yes Soft )

There Is No Biography

: 27
: Yes Soft
« »


Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2022 Yes Soft - All right reserved.
Implemented By Yes Soft Team.