CRA build not working from docker-compose

Viewed 33

I have created a react app using CRA. Build works normally in the terminal but when I try to execute it from the Dockerfile I get the folowing error:

$ react-scripts build
Could not find a required file.
  Name: index.html
  Searched in: /usr/src/app/public
error Command failed with exit code 1.

My Dockerfile:

FROM node:14 AS builder
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
RUN yarn && yarn build

FROM nginx:1.22-alpine
WORKDIR /usr/share/nginx/html
RUN rm -rf ./*
COPY --from=builder /usr/src/app/build .
ENTRYPOINT ["nginx", "-g", "daemon off;"]

Being my first post, please, let me know if more information is needed.

0 Answers
Related