How do you cache Yarn Dependencies for a Docker image build in CircleCI?
The problem is that the result of yarn cache dir
is an external folder, that either doesn't exist in the docker build or is just empty. You've got a couple of options
- Setup a .yarnrc with "cache-folder" set (see https://yarnpkg.com/lang/en/docs/cli/cache/) make a cache folder inside your build directory, and then run
yarn install
outside of the Docker run - Give unspecified amounts of cash to CircleCI to get Docker layer caching enabled, which will speed up builds where there's no package changes
- Try one of the other magic options (e.g https://blog.jondh.me.uk/2018/04/strategies-for-docker-layer-caching-in-circleci/) to manually setup caching