# 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: Final application image FROM python:3.11-slim WORKDIR /app # Copy backend requirements COPY backend/requirements.txt . # Install backend dependencies directly into the final image RUN pip install --no-cache-dir -r requirements.txt # Copy backend application code COPY backend/app /app/app # 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 as a module (most robust method) CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]