Updates to node_modules on image rebuild not reflected in container's node_modules volume #2032
Labels
Affects: Configuration
Related to the configuration of the dev/staging/prod environments, CI, docker, etc. [managed]
Lead: @cdrini
Issues overseen by Drini (Staff: Team Lead & Solr, Library Explorer, i18n) [managed]
Module: Docker
Issues related to the configuration or use of Docker. [managed]
Priority: 3
Issues that we can consider at our leisure. [managed]
Theme: Development
Issues related to the developer experience and the dev environment. [managed]
Type: Refactor/Clean-up
Issues related to reorganization/clean-up of data or code (e.g. for maintainability). [managed]
Milestone
Description
Because we volume mount
./
to/openlibrary
,/openlibrary/node_modules
(which is populated whennpm install
is run inside theDockerfile
) gets rewritten by what's in the local directory. We've solved this issue by adding another volume mount specifically to/openlibrary/node_modules
. This has had the unintended consequence that if the images are rebuilt, even thoughnpm install
is run there, when they are launched, they attach to the volume which contains the old version of/openlibrary/node_modules
. Sonpm install
has to be run again to update the volume.What we want:
npm install
docker-compose up
should NOT require runningnpm install
docker-compose up
should have the same npm versions from the image.External links:
docker-compose up
with the correct and latestnode_modules
from the base image.The article has a very good description of the node_modules problem in the section "The node_modules Volume Trick" and how mounting the local dev dir overwrites the installed image modules with the empty host
node_modules
. The blue / red filenames is a great way to illustrate a problem (I have found) difficult to describe clearly.The text was updated successfully, but these errors were encountered: