# Stage 1: Build the React frontend FROM node:18-alpine AS frontend-builder WORKDIR /app/frontend COPY frontend/package*.json ./ RUN npm install COPY frontend/ . RUN npm run build # Stage 2: Install backend dependencies FROM python:3.11-slim AS backend-builder WORKDIR /app COPY backend/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Stage 3: Final application image FROM python:3.11-slim WORKDIR /app # Copy installed Python packages from the backend-builder stage COPY --from=backend-builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages # Copy backend application code and start script COPY backend/app /app/app COPY backend/start.sh /app/start.sh RUN chmod +x /app/start.sh # Copy the built React app from the frontend-builder stage COPY --from=frontend-builder /app/frontend/build /app/static # Expose the port the app runs on EXPOSE 8000 # Run the application using the start script CMD ["sh", "start.sh"]