anthill / 6brain

0 stars 3 forks source link

Npm install is too expensive #68

Open vallettea opened 8 years ago

vallettea commented 8 years ago

Yesterday we update 6bin on a sensor and we accidentally did it over 3G. The reinstall of 6bin twice consumed 10Mo of data. We need to optimise this:

DavidBruant commented 8 years ago

For more context on this issue:

vallettea commented 8 years ago

@DavidBruant i managed to install node 4.2.3 and npm 3.5 on rpi !

vallettea commented 8 years ago

@oncletom I did not get your remark on twitter: you should not perform an 'npm up': your CI generate an artefact of successful build, you deploy a diff/zip

vallettea commented 8 years ago

A npm install with no new package installed cost 300ko up and 300ko down (for this package).

vallettea commented 8 years ago

installing 6bin costs 2.6Mo

thom4parisot commented 8 years ago

Will do – did not manage to find the time today.

tl;dr pushing a tar file (or a diff of two tarballs) of an install which has proven to work is more reliable than running as many installs/updates as devices (which means network roundtrips over 3G for nothing and race conditions/bugs inherent to npm/network which make the install state unpredictable).

Similar to Docker: you push an image you ensured the install + isolated tests were successful instead of running the install as many times as you deploy.

You just need to build on the same hardware because of you have native modules but you can automate the build on one of your device or use a Raspberry Pi cloud provider). Or you can also ignore deploying binaries and call npm rebuild on the devices, should be even lighter to deploy.

vallettea commented 8 years ago

Thanks @oncletom Never heard of npm rebuild before. I guess you're right, we should try to mimic docker. We stopped using the hypriot image that enables to use docker on rpi for various reasons but we could think again. So here are the alternatives I see:

Docker

Npm

Git

vallettea commented 8 years ago

interesting for the docker solution: https://resin.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub/