# Stage 1: Build React frontend FROM node:18-slim as build # Set working directory WORKDIR /app # Copy project files COPY . . # Install dependencies and build the frontend RUN npm install RUN npm run build # Stage 2: Backend + Nginx setup FROM node:18-slim # Set working directory for the backend WORKDIR /app # Copy backend files and entrypoint script COPY . . COPY entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/entrypoint.sh # Install backend dependencies RUN npm install # Copy the React frontend build into a directory for Nginx RUN mkdir -p /usr/share/nginx/html COPY --from=build /app/dist /usr/share/nginx/html # Install Nginx RUN apt-get update && apt-get install -y nginx && apt-get clean # Copy Nginx configuration COPY /docker/nginx.conf /etc/nginx/conf.d/default.conf # Expose the ports EXPOSE 80 3001 # Start both the backend and Nginx CMD ["/usr/local/bin/entrypoint.sh"]