September 2018
Intermediate to advanced
764 pages
20h 6m
English
At the moment, we are copying the src directory into the container, and then using it to build our application. However, after the project is built, the src directory and other files like package.json and yarn.lock are not required to run the application:
$ docker exec -it 27459e1123d4 sh~ $ pwd/home/node~ $ du -ahd14.0K ./.ash_history588.0K ./dist4.0K ./.babelrc4.0K ./package.json20.0K ./spec128.0K ./yarn.lock564.0K ./src138.1M ./.cache8.0K ./.yarn
98.5M ./node_modules237.9M .
You can see that 138.1 MB is actually being used for the Yarn cache, which we don’t need. Therefore, we should remove these obsolete artifacts, and leave only the dist and node_modules directories.
After the RUN ["yarn", "run", "build"] instruction, ...
Read now
Unlock full access