An yarn
cache compatible Dockerfile, for building node.js images faster.
Clone this gist into your project root, and add it to your source control.
Change the image service-name:latest
tag to your project name in the Dockerfile
and build.sh
files.
Then, always build your image using the build.sh
script.
$ chmod +x ./build.sh
$ ./build.sh
In case someone arrives here wondering why yarn install doesn't even cache locally, check out your COPY commands beforehand, and split them in two:
If you just do
COPY . ./
, it's very very likely something has changed in your project, and caching will never work.