简体   繁体   English

如何跳过针对Node.js buildpack的重建和构建

[英]How to skip rebuild and build for Node.js buildpack

When deploying applications to CloudFoundry via the Node.js buildpack 通过Node.js buildpack将应用程序部署到CloudFoundry时

  • npm rebuild npm重建
  • npm install npm安装

are executed every time during staging. 在登台期间每次执行。

Both operations can take a significant amount of time, especially for applications with complex vendored dependency trees. 两种操作都可能花费大量时间,尤其是对于具有复杂的供应商依赖性树的应用程序而言。

My applications do not need any native modules and have all their dependencies vendored. 我的应用程序不需要任何本机模块,并且已供应其所有依赖项。

I search a way to to skip the rebuild and install steps completely during staging. 我搜索一种在过渡期间完全跳过重建和安装步骤的方法。


Edit : I am aware of the workarounds possible by manipulating package.json as suggested in this SO answer . 编辑 :我知道可以通过解决SO所建议的package.json的变通办法。

Other parts of the build system depend on manifest being true to the actual requirements of the applications, so this is not possible for me. 构建系统的其他部分取决于清单是否符合应用程序的实际需求,因此这对我来说是不可能的。

From the Cloud Foundry & NodeJS build pack perspective, you cannot skip the build step . 从Cloud Foundry和NodeJS构建包的角度来看,您不能跳过构建步骤 It's going to run with Yarn or with NPM, and with NPM it'll either run npm install or npm rebuild . 它将与Yarn或NPM一起运行,并与NPM一起运行npm installnpm rebuild

You have two options: 您有两种选择:

  • You can vendor your dependencies . 您可以供应依赖项 If you truly do not have any native dependencies then rebuild will basically be a no-op. 如果您确实没有任何本机依赖关系,则rebuild基本上将是无所事事。 If you do have native libraries, which most people do, you can run npm install and cf push from an Ubuntu Trusty VM or docker container where it can build and vendor even the native libraries. 如果您确实拥有大多数人都喜欢的本机库,则可以从Ubuntu Trusty VM或docker容器中运行npm installcf push ,以在其中构建和供应甚至本机库。 Again, when you push this will still run npm rebuild but if everything is vendored it should basically be a no-op. 同样,当您按下该按钮时,它仍将运行npm rebuild但是如果所有内容都已提供,则基本上应该是无操作的。

  • You can fork the NodeJS build pack and change the operations to occur in the order that you want. 您可以派生NodeJS构建包并更改操作以按所需顺序进行。 This would probably require you to edit the supply code here and add a flag or some way to skip the rebuild. 这可能需要您在此处编辑供应代码并添加标志或某种方式来跳过重建。

Hope that helps! 希望有帮助!

You can add --ignore-scripts flag to skip run pre and post install hooks 您可以添加--ignore-scripts标志跳过运行安装挂钩

$ npm install --ignore-scripts

http://blog.npmjs.org/post/141702881055/package-install-scripts-vulnerability http://blog.npmjs.org/post/141702881055/package-install-scripts-vulnerability

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM