Liondancer
Liondancer

Reputation: 16489

Could not find a required file for docker build

I keep getting a Could not find a required file for my docker build and I am not sure why. I am new to docker so is there a way I can "step through" the build process? I am running

docker build .  

when I am INSIDE the /redribbon-client directory

output:

$ docker build .
Sending build context to Docker daemon  315.9MB
Step 1/6 : FROM node:alpine as builder
 ---> 4acd7c5129dc
Step 2/6 : WORKDIR "/client"
 ---> Using cache
 ---> c57cd917bb87
Step 3/6 : COPY ./package.json .
 ---> Using cache
 ---> 4098880ac4a5
Step 4/6 : RUN npm install
 ---> Using cache
 ---> 1015d2aec06c
Step 5/6 : COPY ./src/ .
 ---> Using cache
 ---> 5c895812a8c8
Step 6/6 : RUN npm run start
 ---> Running in 63ff064c6e84

> [email protected] start /client
> react-scripts start

Could not find a required file.
  Name: index.html
  Searched in: /client/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-02-04T03_06_26_933Z-debug.log

project structure:

/redribbon-client
  Dockerfile
  /src
  /public
  package.json

Dockerfile

FROM node:alpine as builder

WORKDIR "/client"

COPY ./package.json .
RUN npm install

COPY ./src/ .

RUN npm run start

Upvotes: 0

Views: 214

Answers (1)

Nguyen Lam Phuc
Nguyen Lam Phuc

Reputation: 1431

You will need to copy the public folder over as well. The error stated that it was trying to look for public folder

Could not find a required file.
  Name: index.html
  Searched in: /client/public

Can you try again with the new Dockerfile?

FROM node:alpine as builder

WORKDIR "/client"

COPY ./package.json .
RUN npm install

COPY ./src/ .
COPY ./public/ .

RUN npm run start

Alternatively, you can copy everything over like this: COPY . .

Upvotes: 1

Related Questions