I am completely lost with respect to the docker filesystem. After struggling for a couple of days and reading the documentation, I still don't understand the underlying cause of this problem.
Minimum reproducible example:
docker-compose.yml:
version: "3" services: web: build: context: ./webapp dockerfile: ./Dockerfile volumes: - './:/webapp' - '/webapp/node_modules' ports: - '3000:3000' stdin_open: true webapp/Dockerfile:
FROM node:fermium #COPY scripts/ /scripts COPY ./ /rxc-voice COPY ./package.json /rxc-voice WORKDIR /rxc-voice RUN npm install -q EXPOSE 3000 CMD ["npm", "start"] My current directory structure is as so:
. ├── backend │ ├── Dockerfile │ └── api ├── docker-compose.yml ├── README.md ├── webapp │ ├── Dockerfile │ ├── etc │ ├── init.ts │ ├── node_modules │ ├── package.json │ ├── package-lock.json │ ├── public │ ├── README.md │ ├── src │ └── tsconfig.json ├── scripts # used for building in other directories └── deploy This will pull this error:
web_1 | npm ERR! code ENOENT web_1 | npm ERR! syscall open web_1 | npm ERR! path /rxc-voice/package.json web_1 | npm ERR! errno -2 web_1 | npm ERR! enoent ENOENT: no such file or directory, open '/rxc-voice/package.json' web_1 | npm ERR! enoent This is related to npm not being able to find a file. web_1 | npm ERR! enoent when trying to run despite the fact that everything should be copied to the image
Ideally, the docker-compose uses the . context and switches pwd in the Dockerfile, but I can't get that to work either.
Interestingly, docker build . inside of the webapp directory works fine (after modifying the Dockerfile to do the same thing with different directory structure.
没有评论:
发表评论