We have an internal CI/CD server running private GitLab. It has the source code of our NodeJS project. We would like to run CI/CD and have it deploys to our on-premises production server. (Let's assume we are using the master
branch).
Here are two most common methods I found on the internet:
- Run
git pull
on the production server, run whatever build tasks needed (npm install
, minify, etc...), and restart the service - Build the source codes on CI/CD server, rsync the built artifacts to production server and restart
Surprisingly, most of the examples I found on the internet uses method 1. This method requires the production server to have public internet access which may not be possible for many cases.
My question: is method 1 really the best way to deploy a NodeJS application to a production server? If yes, what is the reason?