如何解决Docker 节点图像在图像中可用时无法识别 node_modules 文件夹
我有一个 Next.js 应用程序,我想使用 Docker compose 运行它
我的docker.compose.yml
:
version: "3.6"
services:
...
next:
container_name: next
build:
context: ./frontend/next
dockerfile: Dockerfile.development
restart: always
ports:
- 3000:3000
volumes:
- ./frontend/next:/frontend-app
- ./frontend/next/package.json:/frontend-app/package.json
- ./frontend/next/yarn.lock:/frontend-app/yarn.lock
而我的 ./frontend/next/Dockerfile.development
是:
FROM mhart/alpine-node
RUN mkdir /frontend-app
workdir /frontend-app
copY package.json yarn.lock ./
RUN yarn install
copY . .
EXPOSE 3000
CMD ["yarn","dev"]
当我运行 docker-compose build
然后 docker-compose up
我得到这个错误:
next | yarn run v1.22.10
next | $ next dev
next | /bin/sh: next: not found
next | error Command Failed with exit code 127.
next | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
运行 docker-compose build
时,它表明 yarn install 运行正常。
即使我在我的图像中运行 shell 并执行 ls /frontend-app
,我也会得到 node_modules
存在。
我在这里做错了什么?
编辑:
我的 ./frontend/next/.dockerignore
是
.next/
node_modules/
Dockerfile
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。