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=<デプロイ先のプロジェクト名> deploy <対象ディレクトリ>
デプロイ前にプロジェクトをビルドする場合は、 --prod オプションを使用して devDependencies のインストールをスキップします。
pnpm --filter=<デプロイ先のプロジェクト名> --prod deploy <対象ディレクトリ>
Docker イメージでの使用方法。 モノレポですべてをビルドしたら、モノレポベースイメージをビルドコンテキストとして使用する 2 番目のイメージで、または追加のビルド ステージで、これを行います。
# 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"]
Options
--dev, -D
NODE_ENV によらず devDependencies 内の依存のみをインストールします。
--no-optional
optionalDependencies をインストールしません。
--prod, -P
devDependencies のパッケージはインストールされません。
--filter <package_selector>
詳細についてはフィルタリングに関するドキュメントを参照してください。
デプロイされたプロジェクトに含まれるファイル
By default, all the files of the project are copied during deployment but this can be modified in one of the following ways which are resolved in order:
- The project's
package.jsonmay contain a "files" field to list the files and directories that should be copied. - If there is an
.npmignorefile in the application directory then any files listed here are ignored. - If there is a
.gitignorefile in the application directory then any files listed here are ignored.