# stage1 - build react app first
FROM node:20-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY ./app/package.json /app/
COPY ./app/yarn.lock /app/
RUN yarn
COPY /app /app
RUN yarn build

# stage 2 - build the final image and copy the react build files
FROM nginx:1.25.0-alpine
COPY --from=build /app/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
