# Stage 1: Build the React app
FROM node:18 as builder

# Set the working directory
WORKDIR /app

# Copy dependency files to leverage Docker's cache
COPY package.json .
COPY package-lock.json .

# Install dependencies
RUN npm install

# Copy the rest of the application files
COPY . .

# Build the React app for production
RUN npm run build

# For docker-compose, we stop here and just copy the build files
# The nginx container will serve these files