From 81dce801ce2771fa2471701e464823dfca2d6499 Mon Sep 17 00:00:00 2001 From: Emma Thorpe Date: Fri, 21 Aug 2026 15:21:12 +0100 Subject: [PATCH] build: base the image on Alpine to drop 387 MB of graphics stack Debian's ffmpeg package depends on libavdevice, which can capture from and render to X11, Wayland, SDL and OpenGL. That pulls in Mesa, and Mesa pulls in LLVM for its software rasteriser -- 127 MB of it -- plus Z3 at 27 MB and a speech synthesiser at 28 MB, in an image whose only job is to encode MP3s on a headless NAS. Alpine's ffmpeg brings none of that. The runtime image goes from 576 MB to 189 MB. Small X11 and Wayland client libraries remain, but they are kilobytes rather than megabytes. The test suite passes unchanged inside the new image, which is the point of running it there: the encoder under test is now a musl build from a different distribution, and the tests cover exactly the tag, cover art and container behaviour that could have differed. Verified separately that a CBR 256 encode comes out at the expected bitrate with non-ASCII tags intact. Co-Authored-By: Claude Opus 5 (1M context) --- Dockerfile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f50791..b646258 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,14 @@ -FROM python:3.13-slim AS runtime +# Alpine rather than Debian slim purely because of ffmpeg's dependencies. +# Debian's ffmpeg depends on libavdevice, which can render to X11, Wayland and +# OpenGL, so it drags in Mesa and with it LLVM (127 MB) and Z3 (27 MB) to +# encode an MP3 on a headless NAS. Alpine's build brings none of that: 576 MB +# down to 189 MB. +FROM python:3.13-alpine AS runtime ENV PYTHONUNBUFFERED=1 # ffmpeg does the encoding; the application itself has no Python dependencies. -RUN apt-get update \ - && apt-get install --no-install-recommends -y ffmpeg \ - && rm -rf /var/lib/apt/lists/* +RUN apk add --no-cache ffmpeg WORKDIR /app COPY pyproject.toml README.md ./