Couldn’t find a `pages` directory. Please create one under the project root. while creating docker image

I am trying to create a docker image but I am getting this error(Couldn’t find a pages directory. Please create one under the project root) in the "npm run build" step. But I have that directory in my application root folder. In my local server it is running fine and creating .next folder. My folder structure is ex: app/pages/index.js
I don’t know why it is failing in the docker build. Can you guys help me with this?

Below is my Dockerfile

FROM node:14-alpine

RUN mkdir -p /usr/src/next-website

WORKDIR /usr/src/next-website

COPY package*.json ./

RUN npm i

RUN npm run build

COPY . .

EXPOSE 94

CMD ["node", "server.js"]

Thanks in advance.

Source: Docker Questions

LEAVE A COMMENT