pnpm deploy
Desplega un paquete desde un workspace. Durante el despliegue, los archivos del paquete desplegado se copian al directorio de destino. All dependencies of the deployed package, including dependencies from the workspace, are installed inside an isolated node_modules
directory at the target directory. El directorio de destino contendrá un paquete portátil que puede ser copiado a un servidor y ejecutado sin pasos adicionales.
Uso:
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>
Uso en una imagen docker. Después de generar todo en su monorepo, haga esto en una segunda imagen que use su imagen base monorepo como contexto de construcción o en una etapa de generación adicional:
# 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"]
Opciones
--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>
Archivos incluidos en el proyecto desplegado
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.json
may contain a "files" field to list the files and directories that should be copied. - If there is an
.npmignore
file in the application directory then any files listed here are ignored. - If there is a
.gitignore
file in the application directory then any files listed here are ignored.