How do you cache Yarn Dependencies for a Docker image build in CircleCI? How do you cache Yarn Dependencies for a Docker image build in CircleCI? docker docker

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


As per Tom's first point, putting this anywhere before RUN yarn install within same Docker build stage can help by caching all yarn cache to volumed directory.

ENV YARN_CACHE_FOLDER=/usr/local/yarn-cacheVOLUME /usr/local/yarn-cache