Heroku is great. But every time I deploy, Heroku seems to like to redownload and rebuild all the packages. With socket.io
and mailparser
this is taking around 3 minutes.
Is there a way to speed up the deployment process? Is there a way to tell Heroku that it can cache these items? Or can I upload prebuilt node_modules
?
These may be conducted without any need for approval from Heroku, so long as they're limited to 10,000 requests/second for any given application. This applies to all regions for the Common Runtime.
The easiest is to add a . slugignore file to your application to tell the slug compiler to ignore any unnecessary files in your application, such as static assets. This can be helpful in determining where large files are. You may also find that clearing the build cache helps reduce the size of the slug.
To preserve your dyno hours from burning out or wasting, Heroku puts your app to sleep after 30 minutes of inactivity. How generous! This is what makes your app is slow to load.
Heroku makes it easy to collaborate with others. You can permit collaborators to deploy changes to your apps, scale them, and access their data, among other operations.
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 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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With