# Stage 1: Build the React app
FROM node:18.17.0 AS build

WORKDIR /livequiz

COPY package.json ./
COPY package-lock.json ./
COPY ./ ./

RUN npm install
RUN npm install --global serve
RUN npm run build

# Stage 2: Create the production image with Nginx
FROM nginx:1.18.0

# Copy the built React app from the previous stage
COPY --from=build livequiz/build /usr/share/nginx/html/

# Expose port 8083 for Nginx
EXPOSE 80

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
