deploy pnpm
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.
Uso:
pnpm -- filter=<deployed project name> deploy <target directory>
Caso você construa seu projeto antes da implantação, use também a opção --prod para pular a instalação de devDependencies.
pnpm --filter=<deployed project name> --prod deploy <target directory>
Usando em uma imagem Docker. Depois de compilar tudo em seu monorepo, faça isso em uma segunda imagem que usa sua imagem base do monorepo como contexto de compilação ou em um estágio de compilação 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"]
Opções
--dev, -D
Apenas as devDependencies serão instaladas, independentemente do NODE_ENV.
--no-optional
Não serão instaladas dependências opcionais - optionalDependencies.
--prod, -P
Pacotes em devDependencies não serão instalados.
--filter <package_selector>
Arquivos incluídos no deploy do projeto
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.