# Stage 1: Build stage FROM python:slim AS builder WORKDIR /app COPY requirements.txt . RUN apt-get update && apt-get install -y --no-install-recommends gcc libffi-dev libssl-dev RUN pip install --no-cache-dir -r requirements.txt && rm -rf /var/lib/apt/lists/* # Stage 2: Final stage FROM python:slim WORKDIR /app # Copy only necessary files from the builder stage COPY --from=builder /usr/local/lib/python3.*/dist-packages /usr/local/lib/python3.*/dist-packages COPY . . EXPOSE 8080 CMD ["python", "main.py"]