pnpm deploy

Added in: v7.4.0

Deploy a package from a workspace.

Usage:

  1. pnpm --filter=<deployed project name> deploy <target directory>

In case you build your project before deployment, also use the --prod option to skip devDependencies installation.

  1. pnpm --filter=<deployed project name> --prod deploy <target directory>

Usage in a docker image. After building everything in your monorepo, do this in a second image that uses your monorepo base image as a build context or in an additional build stage:

  1. # syntax=docker/dockerfile:1.4
  2. FROM workspace as pruned
  3. RUN pnpm --filter <your package name> --prod deploy pruned
  4. FROM node:18-alpine
  5. WORKDIR /app
  6. ENV NODE_ENV=production
  7. COPY --from=pruned /app/pruned .
  8. ENTRYPOINT ["node", "index.js"]

Options

--dev, -D

Only devDependencies are installed regardless of the NODE_ENV.

--no-optional

optionalDependencies are not installed.

--prod, -P

Packages in devDependencies won’t be installed.

--filter <package_selector>

Read more about filtering.

Files included in the deployed project

By default, all the files of the project are copied during deployment. The project’s package.json may contain a “files” field to list the files and directories that should be copied.