Перейти к основному содержимому
Версия: 9.x

pnpm deploy

Deploy a package from a workspace. During deployment, the files of the deployed package are copied to the target directory. All dependencies of the deployed package, including dependencies from the workspace, are installed inside an isolated node_modules directory at the target directory. The target directory will contain a portable package that can be copied to a server and executed without additional steps.

Использование:

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.

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

Использование в образе docker. После построения всего в своем monorepo, сделайте это во втором образе, использующий базовый образ monorepo в качестве контекста сборки или в дополнительном этапе сборки:

# syntax=docker/dockerfile:1.4

FROM workspace as pruned
RUN pnpm --filter <your package name> --prod deploy pruned

FROM node:18-alpine
WORKDIR /app

ENV NODE_ENV=production

COPY --from=pruned /app/pruned .

ENTRYPOINT ["node", "index.js"]

Опции

--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 &lt;package_selector>

Read more about filtering.

Файлы, включенные в развернутый проект

По умолчанию во время развертывания копируются все файлы проекта. The project's package.json may contain a "files" field to list the files and directories that should be copied.