https://github.com/oresoftware/package-sha
This probably does not work as intended. Looking for other solutions.
https://github.com/oresoftware/package-sha
Last synced: 8 months ago
JSON representation
This probably does not work as intended. Looking for other solutions.
- Host: GitHub
- URL: https://github.com/oresoftware/package-sha
- Owner: ORESoftware
- License: mit
- Created: 2019-05-02T01:24:05.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-02T19:05:34.000Z (almost 7 years ago)
- Last Synced: 2025-05-18T16:54:45.366Z (9 months ago)
- Language: Shell
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
### Use this in Dockerfiles to determine if NPM install needs to re-occur
normally we can just use git caching like so:
```Dockerfile
COPY package.json .
RUN npm install # if the package.json file has not changed, then this line's image will be re-used
COPY . .
```
But what if we pull new code via git in the image instead of outside the image? So we do:
```Dockerfile
RUN CACHEBUST 1
RUN git pull # always re-occurs
RUN package_sha --check || ( npm install && package_sha --installed )
```
The nice thing about this technique is that the sha of the whole package.json file is not used,
only the dependencies objects in package.json are compared for equality. so if you bump the version in package.json,
but the dependencies are the same, then they won't get reinstalled.