# ---- Stage 1: Builder ---- FROM python:3.13-slim-trixie AS builder # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Install build dependencies RUN apt-get update && \ apt-get install -y --no-install-recommends \ gcc \ g++ \ libffi-dev \ ffmpeg \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy requirements and install dependencies into /install COPY requirements.txt . RUN pip install --prefix=/install --no-cache-dir -r requirements.txt # Copy the rest of the app COPY . . # ---- Stage 2: Runtime ---- FROM python:3.13-slim-trixie # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Install runtime dependencies only RUN apt-get update && \ apt-get install -y --no-install-recommends \ ffmpeg \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy only the installed Python packages from the builder stage COPY --from=builder /install /usr/local # Copy your application code COPY --from=builder /app /app # Make entrypoint executable RUN chmod +x /app/entrypoint.sh # Set entrypoint ENTRYPOINT ["/app/entrypoint.sh"]