Building Docker images of node applications – The npm install issue

I am working on a Docker container array for a node application. Developers should work with it, it should be good to go to testing and production, Jenkins should be able to use it. There should be two seperate containers: One for running the ready-built code (run-container) and one for building everything on Jenkins and watching during development (build-container).

This presents me with a problem node developers on Docker might face often but I had my problems finding a solution for it.

The challenge:
Checkout the code and run docker-compose up to get everything you want including a ready run-container and a local bind mount to the build-container to react to code changes (grunt-watch in this case).

Both containers would then share the bind mount so they get the code changes and, via the build-container, also the built files (scss in this case).

To be continued…

Important read: – Lessons from Building a Node App in Docker
The method of voluming the node_modules folder is also referenced in – Using Docker Compose for NodeJS Development