Speed up deployment on Heroku [duplicate] Speed up deployment on Heroku [duplicate] heroku heroku

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.


One thing I did to speed up process was to add .slugignore file to the main folder and add all the files and folders I did not want to run the app.

Sample content of .slugignore file:
working
mockups
*.psd
*.pdf


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.

  1. Check in node_modules in a separate branch: The core Node.js maintainers actually recommend checking in the node_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 separate production branch with a different .gitignore file that doesn't ignore node_modules. When you want to deploy, just do a rebase from your master and node_modules will be checked in. At least this keeps your master branch free from dependencies.

  2. Add a preinstall script to package.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.

  3. Modify the heroku-buildpack-nodejs: Integrate the outstanding pull request with node_modules caching:

    heroku config:set BUILDPACK_URL=https://github.com/opdemand/buildpack-nodejs.git