I would like to run a binary npm file in a container which was installed by another container.
I understand that it is possible using a shared volume.
I have the following configuration:
docker-compose.yml
version: '3'
services:
cypress:
build:
context: .
dockerfile: Dockerfile-cypress
volumes:
- ./node_modules:/app/node_modules
test:
build:
context: .
dockerfile: Dockerfile
depends_on:
- cypress
environment:
- ENV=development
volumes:
- ./node_modules:/app/node_modules
Dockerfile-cypress
FROM cypress/base:10
WORKDIR /app
COPY . /app
RUN npm install uuid
RUN $(npm bin)/uuid
Dockerfile
FROM node:10.13
COPY . /app
WORKDIR /app
RUN $(npm bin)/uuid
When running docker-compose build
it fails because:
Step 5/5 : RUN $(npm bin)/uuid
---> Running in 1d86293ea47c
/bin/sh: 1: /app/node_modules/.bin/uuid: not found
ERROR: Service 'test' failed to build: The command '/bin/sh -c $(npm bin)/uuid' returned a non-zero code: 127
What is wrong in my configuration that the volume is not available in the second container?