Langsung ke konten utama
Versi: Selanjutnya

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.

Penggunaan:

pnpm --filter=<deployed project name> terapkan <target directory>

Jika Anda membangun proyek Anda sebelum deploy, gunakan juga opsi --prod untuk melewati instalasi devDependencies.

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

Penggunaan di docker image. Setelah membangun keseluruhan yang ada pada monorepo anda, lakukan hal ini pada image kedua dimana digunakan pada image monorepo dasar anda sebagai konteks pembuatan atau dalam tahap pembangunan tambahan:

# 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 / dipangkas .

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

Pengaturan

--dev, -D

Only devDependencies are installed.

--no-optional

optionalDependencies tidak akan diinstal.

--prod, -P

Paket dalam devDependencies tidak akan diinstal.

--filter <package_selector>

Baca lebih lanjut tentang filtering.

Berkas-berkas yang termasuk di dalam projek yang dideploy

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:

  1. The project's package.json may contain a "files" field to list the files and directories that should be copied.
  2. If there is an .npmignore file in the application directory then any files listed here are ignored.
  3. If there is a .gitignore file in the application directory then any files listed here are ignored.