should i build my application inside docker [closed]

I am developing a web app using VUEjs, and I’m trying to better understand how to use docker correctly.

why should I run ‘npm install’ or ‘npm build’ when building my docker image? wouldn’t that make my image heavier for no reason? The way I thought it would be best is to run npm build before I even create start creating my image and the just copy ‘dist’ into the container, that way the end container contains only the actual build and doesn’t have a ton of node modules and dependencies it doesn’t need.

Source: Docker Questions