chore(userbot): optimize Dockerfile with multi-stage build and static ffmpeg
Deploy to Server / deploy (push) Has been cancelled
Deploy to Server / deploy (push) Has been cancelled
- 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
This commit is contained in:
+18
-8
@@ -1,17 +1,27 @@
|
|||||||
|
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
|
FROM python:3.11-slim
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
git wget ffmpeg mediainfo && \
|
git \
|
||||||
rm -rf /var/lib/apt/lists/*
|
mediainfo \
|
||||||
|
wget \
|
||||||
|
xz-utils \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY requirements.txt /app/
|
RUN wget -qO- https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz | \
|
||||||
|
tar xJ && \
|
||||||
RUN python -m pip install --no-cache-dir --upgrade pip && \
|
cp ffmpeg-*-static/ffmpeg /usr/local/bin/ && \
|
||||||
python -m pip install --no-cache-dir -r /app/requirements.txt
|
cp ffmpeg-*-static/ffprobe /usr/local/bin/ && \
|
||||||
|
rm -rf ffmpeg-*
|
||||||
|
|
||||||
|
COPY --from=builder /root/.local /usr/local
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user