To be able to do dev both inside and out of Docker the node modules folders need to be completely separate to avoid clashing.
The code that creates the directory:
volumes:
- .:/opt/node_app/app
This only happens when the directory doesn't exist yet, and with the other code in the compose it will prevent the folder from being populated by content from the Docker container (which is good)
The problem is that the empty gets created as root, meaning npm installs outside of docker fail.
The simplest workarounds are to either create the directory before ever running docker compose up or don't use . for the volume and instead explicitly specify the dir that the source code for the app is in.
Is there a nicer way to handle this?
To be able to do dev both inside and out of Docker the node modules folders need to be completely separate to avoid clashing.
The code that creates the directory:
volumes: - .:/opt/node_app/appThis only happens when the directory doesn't exist yet, and with the other code in the compose it will prevent the folder from being populated by content from the Docker container (which is good)
The problem is that the empty gets created as root, meaning npm installs outside of docker fail.
The simplest workarounds are to either create the directory before ever running docker compose up or don't use
.for the volume and instead explicitly specify the dir that the source code for the app is in.Is there a nicer way to handle this?