I built an image from a docker file to run node and copy in a simple node express app which works perfectly. The image builds I can run a container and bash in and the local files are copied. When I use this image in a docker-compose file along with a mongo image the containers build but the node container fails to run with an error is the package.json is missing.
The error returned is
report-node exited with code 254
report-node | npm ERR! path /usr/src/app/package.json
report-node | npm ERR! code ENOENT
report-node | npm ERR! errno -2
report-node | npm ERR! syscall open
report-node | npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
report-node | npm ERR! enoent This is related to npm not being able to find a file.
report-node | npm ERR! enoent
report-node |
report-node | npm ERR! A complete log of this run can be found in:
report-node | npm ERR! /root/.npm/_logs/2019-02-26T10_55_05_562Z-debug.log
report-node exited with code 254
dockerfile
FROM node
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 4000
CMD [ "npm", "run", "dev" ]
Docker-compose.yml looks like
version: '3'
services:
app:
image: gosmith/node10:latest
container_name: report-node
restart: always
volumes:
- ./:/usr/src/app
working_dir: /usr/src/app
depends_on:
- mongo
environment:
NODE_ENV: development
ports:
- 4000:4000
- 8080:8080
command: npm run dev && npm run serve
mongo:
container_name: mongo
image: mongo
expose:
- 27017
ports:
- 27037:27017
volumes:
- ./data:/data/db
How has the package.json gone missing? Thanks for your help!