When it comes to installing a framework (such as next.js) for a web application into a container what I think I’ve seen people doing is create a next project locally (presumably using npx) and then copying it into the container using the COPY command in the dockerfile. Of course there is more to what happens with the Dockerfile (and .dockerignore) than that (such as installing node / npm and ignoring node_modules).
What I’m wondering is…
Why can’t you
RUN npx create-next-app@latest thus literally installing next.js framework into the container through or by means of the Dockerfile itself? That would be a different approach to installing it on the local file system then copying it into the container.
Is that not a valid approach? Why / why not? Why don’t I see examples of that approach in tutorials and videos?