# Stage 1: Build the Python environment and install dependencies FROM python:3.11-slim-bullseye AS builder WORKDIR /app # Copy only the requirements file first to leverage Docker layer caching COPY requirements.txt . COPY setup.py . RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt COPY . . # Clean up after install (if necessary) RUN rm -rf /root/.cache # Run the app CMD ["python", "app.py"]