# --- Builder Stage --- # Use a full Python image to build dependencies FROM python:3.12 as builder WORKDIR /app # Install dependencies into a virtual environment RUN python -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # --- Runner Stage --- # Use a slim image for the final application FROM python:3.12-slim WORKDIR /app # Copy the virtual environment from the builder stage COPY --from=builder /opt/venv /opt/venv # Copy the application code COPY . . # Set the path to use the virtual environment ENV PATH="/opt/venv/bin:$PATH" # Expose the port and run the app EXPOSE 8000 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]