问题描述
我有一个 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 (将#修改为@)