I'm using Bluemix DevOps Pipelines to deploy a Node.js app to Bluemix as a Cloud Foundry app. It is using the sdk-for-nodejs buildback (although I haven't specified that, it's detecting the package.json
file).
It takes a long time to stage the app. Looking at the logs, this is because it appears to be running npm install
. However, I have set up my pipeline so that npm install
is called in an earlier stage, and the build artifact that is to be deployed already contains the installed node_modules
, so if I have to restage it should be quick, as it shouldn't have to install all the modules again.
This is the command that my pipeline is using to deploy:
cf push "${CF_APP}" -c "npm run start:prod"
My Procfile also contains the same command:
web: npm run start:prod
node: npm run start:prod
(I've tried it both with and without the second line. I think the logs from below were when it contained both lines.)
And indeed towards the end of my deployment logs it says
App mcp-server was started using this command `npm run start:prod`
That script in my package.json
file does not run npm install
:
"scripts": {
...
"start:prod": "cross-env NODE_ENV=production node index.js",
The logs that make it look like it's re-installing the modules are:
Staging...
-----> IBM SDK for Node.js Buildpack v3.11-20170303-1144
-----> Creating runtime environment
NPM_CONFIG_PRODUCTION=true
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.npm (package.json): unspecified (use default)
Resolving node version >=4 via 'node-version-resolver'
Installing IBM SDK for Node.js (4.8.0) from cache
Using default npm version: 2.15.11
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules (exists - skipping)
- bower_components (not cached - skipping)
-----> Building dependencies
Rebuilding any native modules
> [email protected] postinstall /tmp/app/node_modules/radium
> [email protected] install /tmp/app/node_modules/dtrace-provider
> [email protected] install /tmp/app/node_modules/pre-commit
> [email protected] postinstall /tmp/app/node_modules/spawn-sync
> node postinstall
Completed: 0.1% (0.1mb / 78.2mb)
...
Completed: 99.9% (78.2mb / 78.2mb)
inside extract, run complete
Completed: 0.0% (0.0mb / 78.2mb)
Completed: 0.1% (0.0mb / 78.2mb)
Completed: 2.6% (2.0mb / 78.2mb)
Completed: 8.3% (6.5mb / 78.2mb)
Completed: 43.1% (33.7mb / 78.2mb)
Completed: 44.3% (34.7mb / 78.2mb)
Completed: 45.5% (35.6mb / 78.2mb)
Completed: 64.2% (50.2mb / 78.2mb)
Completed: 65.0% (50.8mb / 78.2mb)
Completed: 66.5% (52.1mb / 78.2mb)
Completed: 71.4% (55.8mb / 78.2mb)
> node-gyp rebuild
make: Entering directory `/tmp/app/node_modules/nodejieba/build'
...
> [email protected] postinstall /tmp/app/node_modules/spawn-sync
> npm run clean && npm run build
> [email protected] clean /tmp/app
> [email protected] build /tmp/app
> cross-env NODE_ENV=production webpack --config webpack.config.js
Of particular note are the lines:
Completed: 0.1% (0.1mb / 78.2mb)
...
Completed: 99.9% (78.2mb / 78.2mb)
where I've omitted well over 100 lines where it seems to be installing something very slowly.
And also:
> npm run clean && npm run build
> [email protected] clean /tmp/app
> [email protected] build /tmp/app
> cross-env NODE_ENV=production webpack --config webpack.config.js
which are scripts from my app that I really don't want to be running at deployment time.
I've already tried to tell it to run npm run start:prod
- how can I stop it from running these install steps?