Skip to content

Commit 3daa462

Browse files
committed
Optimise Docker image size
Use runtime library packages instead of -dev packages in the final stage, and replace the apt-managed ffmpeg with a static binary to avoid pulling in ~200 transitive dependencies.
1 parent 6511c69 commit 3daa462

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUN apt-get update \
1313
libsasl2-dev \
1414
gcc \
1515
heimdal-dev \
16+
xz-utils \
1617
&& apt autoclean && rm -rf /var/lib/apt/lists/*
1718

1819
# Install project dependencies with build tools available
@@ -22,6 +23,12 @@ RUN --mount=type=cache,target=/root/.cache/uv \
2223
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
2324
uv sync --frozen --no-install-project --extra ldap --extra voice --no-group dev
2425

26+
# Download and extract static ffmpeg binaries
27+
ADD https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-04-12-13-04/ffmpeg-n7.1.3-43-g5a1f107b4c-linux64-gpl-7.1.tar.xz /tmp/ffmpeg.tar.xz
28+
RUN tar -xf /tmp/ffmpeg.tar.xz -C /tmp/ \
29+
&& mv /tmp/ffmpeg-n7.1.3-43-g5a1f107b4c-linux64-gpl-7.1/bin/ffmpeg /usr/local/bin/ffmpeg \
30+
&& rm -rf /tmp/ffmpeg*
31+
2532
# -------------------------------------------------------------------------------
2633

2734
FROM python:$python_version
@@ -35,11 +42,12 @@ ENV GIT_SHA=$git_sha
3542

3643
RUN apt-get update \
3744
&& apt-get install --no-install-recommends -y \
38-
libmagickwand-dev \
39-
libldap2-dev \
40-
ffmpeg \
45+
imagemagick \
46+
libldap2 \
4147
&& rm -rf /var/lib/apt/lists/*
4248

49+
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
50+
4351
# Install dependencies from build cache
4452
# .venv not put in /app so that it doesn't conflict with the dev
4553
# volume we use to avoid rebuilding image every code change locally

0 commit comments

Comments
 (0)