# Stage 1: Build FROM python:3.9-slim as builder WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir --user -r requirements.txt # Stage 2: Final Image FROM python:3.9-slim WORKDIR /app # Copy only the necessary files from the builder stage COPY --from=builder /root/.local /root/.local COPY . . # Ensure scripts in .local are usable ENV PATH=/root/.local/bin:$PATH # Expose port 7860 (default port for Gradio) EXPOSE 7860 # Run the app when the container launches CMD ["python", "app.py"]