I start to set up a pm2 deployment for a simple Next.js webpage.
If I do pm2 deploy production setup
, the whole git repo is cloned to the server’s webspace (into /public_html/source
).
As Next.js is a Node application, the build process requires additional disk space during build (for node_modules/
). And those modules remain after build at the server.
I don’t want this, as I want to keep the production webspace as lean as possible.
Is there a way to use pm2 in the way that the build appears on a local PC (or within a GitLab CI runner VM) and just the result of the build will be deployed to the server?
If not, do you have any other suggestion how to achieve this?
1