patternjavascriptMinor
How should CI/CD deploy to production environment - copy artifacts or git pull from the server?
Viewed 0 times
thepullhowproductionartifactsenvironmentdeploygitshouldserver
Problem
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
Here are two most common methods I found on the internet:
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?
master branch).Here are two most common methods I found on the internet:
- Run
git pullon 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?
Solution
There are lots of bad examples on the Internet. Doing a
I'm not sure what format
git pull to distribute code is fabulous for development, but prone to all sorts of issues in practice. It should not be used for production deploys without careful consideration of the negative consequences.- What happens when somebody checks out a different branch? You'll be sad when you keep
git pulling and nothing new shows up.
- How do you verify that the machine is running the expected release? You can get this from
git, but it is easier with most artifact systems.
- How do you release to machines that are on an air-gapped network? Simulating your
gitserver on a private network will be a fun time for you.
I'm not sure what format
npm uses for artifacts, but it is also probably a good idea to back them up off of the CI/CD server and use a dedicated set of machines for serving up the artifacts. If you spin up 100 machines at once would your CI/CD server handle it or fall over? Isolating the artifact serving will avoid your CI/CD server being swamped and useless until the deploy is over.Context
StackExchange DevOps Q#6569, answer score: 6
Revisions (0)
No revisions yet.