From c905bbd039f102e7ba4e99b42b436d4f6b7f2157 Mon Sep 17 00:00:00 2001 From: mr-forust Date: Fri, 19 Jun 2026 14:56:37 +0200 Subject: [PATCH] chore(userbot): optimize Dockerfile with multi-stage build and static ffmpeg - Multi-stage build: pip deps built in separate stage - Static ffmpeg binary instead of apt package (avoid 200+ deps) - Keep only git, mediainfo, wget via apt --- Dockerfile | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0091949..6148d41 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,28 @@ +FROM python:3.11-slim AS builder + +WORKDIR /src +COPY requirements.txt . +RUN pip install --no-cache-dir --user -r requirements.txt + FROM python:3.11-slim -WORKDIR /app - RUN apt-get update && apt-get install -y --no-install-recommends \ - git wget ffmpeg mediainfo && \ - rm -rf /var/lib/apt/lists/* + git \ + mediainfo \ + wget \ + xz-utils \ + && rm -rf /var/lib/apt/lists/* -COPY requirements.txt /app/ - -RUN python -m pip install --no-cache-dir --upgrade pip && \ - python -m pip install --no-cache-dir -r /app/requirements.txt +RUN wget -qO- https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz | \ + tar xJ && \ + cp ffmpeg-*-static/ffmpeg /usr/local/bin/ && \ + cp ffmpeg-*-static/ffprobe /usr/local/bin/ && \ + rm -rf ffmpeg-* +COPY --from=builder /root/.local /usr/local COPY . /app +WORKDIR /app ENV PYTHONUNBUFFERED=1 -CMD ["python", "-u", "main.py"] \ No newline at end of file +CMD ["python", "-u", "main.py"]