Nest.js — use pnpm on Docker
Use pnpm for Nest.js Docker deployments
pnpm is an alternative package manager to npm and yarn. In this article I’ll be using pnpm as a package manager for nest.js Docker deployments.
First I’ll create a nest project with pnpm.
nest new nest-pnpm-docker --package-manager=pnpm
I’ll create a .dockerignore file to prevent files from copying to Docker.
I’m also creating a docker-compose.yml file to support docker-compose.
I’ll be using a multi-stage build for this scenario.
Stage: base is a simple node image with pnpm installed globally.
Stage: dependencies handles installation of all dependencies using pnpm.
Stage: build copies all of the node_modules from the stage: dependencies, and runs the build command. It also removes devDependencies after build.