Nest.js — use pnpm on Docker

Alper Çıtak
2 min readAug 21, 2022

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.

.dockerignore

I’m also creating a docker-compose.yml file to support docker-compose.

docker-compose.yml

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: dependencies

Stage: build copies all of the node_modules from the stage: dependencies, and runs the build command. It also removes devDependencies after build.

--

--