0

I am pretty new to Docker and I want to dockerize my react app, the index.html file is under my public folder in the react project. When I run the docker image, it fails and gives me an error stating that the index.html file is missing.

The error:

[email protected] start react-scripts start

Could not find a required file. Name: index.html Searched in: /app/public npm notice npm notice New minor version of npm available! 8.11.0 -> 8.19.2 npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.19.2 npm notice Run npm install -g [email protected] to update! npm notice

Below is the code of my Dockerfile:

FROM node:lts-alpine3.14 as build

RUN apk update && \
  apk upgrade && \
  apk add --no-cache bash git openssh

RUN mkdir /app

WORKDIR /app

COPY package.json .

RUN npm install -g --force npm@latest typescript@latest yarn@latest

RUN npm install

COPY . ./

RUN  npm run build

# ---------------

FROM node:lts-alpine3.14

RUN mkdir -p /app/build

RUN apk update && \
  apk upgrade && \
  apk add git

WORKDIR /app

COPY --from=build /app/package.json .

RUN yarn install --production


COPY --from=build . .

EXPOSE 3000
EXPOSE 3001

ENV SERVER_PORT=3000
ENV API_PORT=3001
ENV NODE_ENV production

CMD ["npm", "start"]


1
  • Please give us the exact error you are seeing. Commented Oct 30, 2022 at 20:55

1 Answer 1

1

Try to attach the shell to the container with

docker exec -it CONTAINER_NAME bash

and see where is index.html file and where you need to copy it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.