# Stage 1: Build stage FROM python:slim AS builder WORKDIR /app COPY requirements.txt . # Install system dependencies required for building Python packages RUN apt-get update && apt-get install -y --no-install-recommends gcc libffi-dev libssl-dev # Install Python dependencies including redis with hiredis support RUN pip install --no-cache-dir -r requirements.txt # Stage 2: Final stage FROM python:slim WORKDIR /app # Copy only necessary files from the builder stage # COPY --from=builder /usr/local/lib/python/dist-packages /usr/local/lib/python/dist-packages # COPY --from=builder /usr/local/lib/python3/dist-packages /usr/local/lib/python3/dist-packages COPY --from=builder /usr/local/lib/python3.*/dist-packages /usr/local/lib/python3.*/dist-packages COPY . . EXPOSE 8080 CMD ["python", "main.py"]