【发布时间】:2021-07-01 13:29:46
【问题描述】:
我一直在用 Next.js 和 PostgreSQL 开发一个应用程序。我有 3 个 dockerfile,一个用于托管我的 next.js 应用程序,两个用于两个 PostgreSQL 数据库。在运行 docker build 和 docker run 时,我对它们中的任何一个都没有问题,但是当我尝试设置 docker compose 并且两个数据库容器运行良好但 Next.js 服务器给了我时
next start
/bin/sh: next: not found
由于 docker-compose 对数据库运行良好,因此我只包括 Dockerfile 和 Next.js 应用程序的 docker-compose 部分。
项目结构:
App>
DB>
UI>
pages>
public>
components>
styles>
.dockerignore
Dockerfile
package.json
tsconfig.json
yarn.lock
.gitignore
docker-compose.yml
readme.md
Dockerfile:
#nodeJS on top of alpine linux
FROM node:alpine
#copy content of UI project directory into new /app directory in image
COPY . /app
#change working directory to /app
WORKDIR /app
#install dependencies and build app
RUN yarn && yarn build
#expose port 3000
EXPOSE 3000
#Start app server upon docker run
CMD ["yarn", "start"]
docker-compose.yml
version: '3'
services:
app:
build:
context: ./UI
dockerfile: Dockerfile
volumes:
- ./UI:/app
ports:
- 4960:3000
有人可以帮我找出我在这里的设置有什么问题吗?就像我说的 docker build 和 docker run 根本没有问题,所以它一定与我的 docker-compose 文件有关。谢谢!
【问题讨论】:
标签: node.js docker docker-compose next.js yarnpkg