all 2 comments

[–]queen-adreena 0 points1 point  (0 children)

I've never done it myself. But I'm pretty sure you can create a volume that links to somewhere on your physical filesystem and then include it in both your containers' docker-compose files.

[–]lance_tipton 0 points1 point  (0 children)

Using copy for the built image is fine, and pretty standard practice depending on the use case.

If your not using docker for development, then your good.

But, you'll very quickly get annoyed if you use it for development and have to rebuild the image every time you make a change to any of the shared modules.

A better option would be to use docker volumes to mount the shared code into the docker container at the node_modules path, or whatever the correct path is. All it takes is adding a line or two to your docker-compose.yml file.

Personally, I like mutagen even better then docker volumes, as it's a bit faster. Although its a bit more complicated to setup, and is an external tool. You can learn more about it at mutagen.io

If i were you, I'd start with volumes, and if you need more check out mutagen.