While building the docker images, after the below steps
If I clean the yarn cache from usr location using below command in docker file, will it affect afterward when I run the docker image?
RUN rm -rf /usr/local/share/.cache/yarn/*
as the docker images size was huge 1.2 GB so I have clean the above location that has close to 450+ MB.
I am using a lower version of docker (for a specific reason) which doesn't support multistage build.
Also, is the above command is equivalent to RUN yarn clean cache?
FROM node:10-alpine
WORKDIR /app
COPY . /app
RUN apk --no-cache add yarn \
&& yarn install \
&& ng build --prod \
&& rm -rf /var/cache/apk/* \
&& rm -rf /usr/local/share/.cache/yarn/*
EXPOSE 3000
CMD ["npm", "run", "start"]
You can safely remove cache files, it will not affect your application. There's even a dedicated command for that:
$ yarn cache clean
With Plug'n'Play, however, clearing the cache will very likely break your application because dependencies are no longer placed in node_modules
. Here's what the documentation says:
In this install mode (now the default starting from Yarn v2), Yarn generates a single .pnp.js file instead of the usual node_modules. Instead of containing the source code of the installed packages, the .pnp.js file contains a map linking a package name and version to a location on the disk, and another map linking a package name and version to its set of dependencies. Thanks to this efficient system, Yarn can tell Node exactly where to look for files being required - regardless of who asks for them!
The location on the disk is cache.
You can get the old behavior back by placing this in your .yarnrc.yml
file.
nodeLinker: node-modules
Read more about Plug'n'Play here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With