# Step 1: Build the application
FROM node:20-alpine AS build
WORKDIR /app

# Copy package files from the client directory
COPY client/package*.json ./
RUN npm install

# Copy the rest of the client application
COPY client/ .
RUN npm run build

# Step 2: Serve with Nginx
FROM nginx:alpine
# Copy the build output from Step 1 to Nginx's serve directory
COPY --from=build /app/dist /usr/share/nginx/html

# Expose port 80
EXPOSE 80

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
