-1

I'm trying to run an react project with a Docker. I build a docker's image, but when i run it I've got the following message:

> react@1.0.0 start /app
> react-scripts start

Could not find a required file.
  Name: index.html
  Searched in: /app/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react@1.0.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react@1.0.0 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/2022-09-13T13_09_01_107Z-debug.log

I don't understand the error, but i do have a index.html file at ./public/index.html

Here is my Dockerfile:

FROM node:14-alpine
WORKDIR /app
COPY . /app
RUN npm install
COPY . app/

EXPOSE 3090

CMD ["npm", "start"]

EDIT: I changed my Dockerfile for the following:

FROM node:14-alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 3090
CMD ["npm", "start"]
RUN ls -la /app
RUN ls -la /app/public

Now i Have the error:

 => ERROR [7/7] RUN ls -la /app/public                                                                                                                                 0.4s
------
 > [7/7] RUN ls -la /app/public:
#11 0.360 ls: /app/public: No such file or directory
------
executor failed running [/bin/sh -c ls -la /app/public]: exit code: 1

I guess it's because i didn't had copy, but i still have the error even if I had the following line :

COPY ./public /app

1 Answers1

0

You could temporarily add a RUN ls -la /app or RUN ls -la /app/public to your Dockerfile. This allows you to see all the directories/files copied into the container.

There is also a possibility that a dockerignore file ignores the files you want to copy.

How do you add items to .dockerignore?

  • I deleted everythong in my .dockerignore for the same result. But I had the two lines suggested and got : => ERROR [7/7] RUN ls -la /app/public 0.4s ------ > [7/7] RUN ls -la /app/public: #11 0.360 ls: /app/public: No such file or directory –  Sep 13 '22 at 13:49