pnpm deploy
Déployer un paquet à partir d'un espace de travail. Lors du déploiement, les fichiers du paquet déployé sont copiés dans le répertoire cible. All dependencies of the deployed package, including dependencies from the workspace, are installed inside an isolated node_modules
directory at the target directory. Le répertoire cible contiendra un paquet portable qui pourra être copié sur un serveur et exécuté sans étapes supplémentaires.
By default, the deploy command only works with workspaces that have the inject-workspace-packages
setting set to true
. If you want to use deploy without "injected dependencies", use the --legacy
flag or set force-legacy-deploy
to true
.
Utilisation :
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>
Utilisation dans une image docker. Après avoir tout généré dans votre monorepo, faites ceci dans une deuxième image qui utilise votre image de base monorepo comme contexte de construction ou dans une étape de génération supplémentaire :
# 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
Only devDependencies
are installed.
--no-optional
optionalDependencies
are not installed.
--prod, -P
Packages in devDependencies
won't be installed.
--filter <package_selector>
--legacy
Force legacy deploy implementation.
By default, pnpm deploy
will try creating a dedicated lockfile from a shared lockfile for deployment. The --legacy
flag disables this behavior and also allows using the deploy command without the inject-workspace-packages=true
setting.
Fichiers inclus dans le projet déployé
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.