# Use Node.js LTS image as base
FROM node:21-alpine as build
WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH
COPY ./reactapp/package.json /app/package.json
RUN npm config --global set 'registry=https://nexuswatchman.t1-consulting.ru/repository/npm-group/'
RUN npm config --global set 'fund=false'
RUN npm install react-scripts@3.0.1 -g --silent
RUN npm install 
# Create environment file
COPY ./reactapp/ /app
RUN npm run build

FROM nginx:stable-alpine
COPY --from=build /app/dist usr/share/nginx/html
COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
