Reputation: 1537
The docker container 'will build' but for some reason 'will not run'. I've trying to resolve this but I think I need a fresh pair of eyes on it.
Here is the code:
Docker file:
FROM cypress/included:6.8.0
WORKDIR /app
COPY . /app
RUN npm install
RUN $(npm bin)/ cypress verify
RUN $(npm bin)/cypress
The docker ignore file
node_modules
The docker-compose.yml file
version: '3'
services:
e2e:
image: cypress
build: .
container_name: cypress
command:
npx cypress run
I got the following error message in my terminal
docker-compose -f docker-compose.yml up
Building e2e
[+] Building 293.8s (9/10)
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 36B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [internal] load metadata for docker.io/cypress/included:6.8.0 0.0s
=> [1/6] FROM docker.io/cypress/included:6.8.0 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 1.14kB 0.0s
=> CACHED [2/6] WORKDIR /app 0.0s
=> [3/6] COPY . /app 0.1s
=> [4/6] RUN npm install 292.0s
=> ERROR [5/6] RUN $(npm bin)/ cypress verify 1.4s
------
> [5/6] RUN $(npm bin)/ cypress verify:
#9 1.387 /bin/sh: 1: /app/node_modules/.bin/: Permission denied
------
executor failed running [/bin/sh -c $(npm bin)/ cypress verify]: exit code: 126
ERROR: Service 'e2e' failed to build
xxx-MacBook-Air CypressDocker %
@mosaad. I just tried your answer. However I got the following error message
=> ERROR [5/6] RUN $(npm bin)/ cypress verify 1.8s
------
> [5/6] RUN $(npm bin)/ cypress verify:
#9 1.705 /bin/sh: 1: /app/node_modules/.bin/: not found
------
executor failed running [/bin/sh -c $(npm bin)/ cypress verify]: exit code: 127
ERROR: Service 'e2e' failed to build
Upvotes: 3
Views: 3552
Reputation: 2371
You should copy after npm install
so that node_modules are copied too.
This should work:
FROM cypress/included:6.8.0
WORKDIR /app
RUN npm install
COPY . /app
RUN $(npm bin)/ cypress verify
RUN $(npm bin)/cypress
Upvotes: 3
Reputation: 1537
Many thanks to everyone who took a moment to take a look at my problem. I rewrote the docker-compose.yml file code again and it now works perfectly. If this can help anyone in the future here is the corrected code.
FROM cypress/included:6.8.0
WORKDIR /app
COPY . /app
RUN npm install
RUN $(npm bin)/cypress verify
RUN $(npm bin)/cypress
Upvotes: 0