I have a docker container that combines 2 node projects into one. Project A is the statsd project and project B is a postgres backend project that writes to a postgres database using the npm package pg. I have both A and B in a 2 separate repos. Then I copy them into the docker image separately like the following in the Dockerfile:
COPY ./statsd/ /opt/statsd/
COPY ./postgres-backend/ /opt/statsd/postgres-backend/
Then I copy the javascript from postgres-backend
to the folder /opt/statsd/backends/
inside docker. At this stage, I can do npm install
inside /opt/statsd
directory with its own package.json specification. However, my postgres-backend
repo has its own package.json file that specifies what dependencies it requires (in this case pg
). I tried switching to the /opt/statsd/postgres-backend
directory and doing npm install
. That only installed in the sub-directory. And when I run statsd.js
in the /opt/statsd
directory it complained that the module pg
was not found.
How can I solve this one project with 2 package.json problem?