Speed up deployment on Heroku [duplicate]
It seems like as of today Heroku is finally caching the node_modules
folder!
-----> Deleting 6 files matching .slugignore patterns.
-----> Node.js app detected
-----> Requested node range: 0.10.x
-----> Resolved node version: 0.10.22
-----> Downloading and installing node
-----> Restoring node_modules from cache
-----> Installing dependencies
-----> Pruning unused dependencies
-----> Caching node_modules directory for future builds
-----> Cleaning up node-gyp and npm artifacts
Build time is like 3 seconds for me now.
I'm running into the same problem.
Some discussion here about caching the node_modules
folder: https://github.com/heroku/heroku-buildpack-nodejs/pull/37
Another idea: https://github.com/heroku/heroku-buildpack-nodejs/issues/25
I'm thinking about a few solutions right now.
Check in
node_modules
in a separate branch: The core Node.js maintainers actually recommend checking in thenode_modules
folder into source control (for apps, not libs). I don't like this. A way to get around it though might be to have a separateproduction
branch with a different.gitignore
file that doesn't ignorenode_modules
. When you want to deploy, just do a rebase from your master andnode_modules
will be checked in. At least this keeps your master branch free from dependencies.Add a
preinstall
script topackage.json
to download compressed dependency zip: You could also add a pre-push git hook to bundle up your dependencies and upload them to S3. This would probably be too slow though.Modify the
heroku-buildpack-nodejs
: Integrate the outstanding pull request withnode_modules
caching:heroku config:set BUILDPACK_URL=https://github.com/opdemand/buildpack-nodejs.git