mirror of
https://github.com/Andre-Bzk/Rezept0r.git
synced 2026-11-15 15:43:04 +01:00
Setting the service up on a new host took 20 to 30 minutes, spent almost entirely in the Debian ffmpeg dependency chain: several hundred packages of X11 and desktop libraries that dpkg unpacks and configures file by file onto an SD card. That cost is paid again on every fresh machine and turned moving the service into a half-hour commitment rather than a routine step. Prebuilt binaries remove the package manager from the build entirely. A cold build with nothing cached now finishes in about four minutes on Pi hardware, verified end to end including audio transcoding. Pinning the dependency versions is unrelated to build speed. It prevents a rebuild months from now from silently resolving versions other than those the running container was tested with.
36 lines
1.2 KiB
Docker
36 lines
1.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
FROM python:3.12-slim-bookworm
|
|
|
|
ARG TARGETARCH
|
|
|
|
# ffmpeg + ffprobe as static binaries (yt-dlp needs both for audio extraction).
|
|
# The Debian package pulls in ~400 MB of X11/desktop dependencies that dpkg then
|
|
# unpacks file by file — on an SD card that alone dominates the build time.
|
|
COPY --from=mwader/static-ffmpeg:7.1 /ffmpeg /ffprobe /usr/local/bin/
|
|
|
|
# gosu drops privileges in the entrypoint; the binary avoids an apt transaction
|
|
ADD --chmod=755 https://github.com/tianon/gosu/releases/download/1.17/gosu-${TARGETARCH} /usr/local/bin/gosu
|
|
|
|
WORKDIR /app
|
|
|
|
COPY requirements.txt .
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
pip install --prefer-binary -r requirements.txt
|
|
|
|
# Placed after pip: the "latest" URL changes with every yt-dlp release and would
|
|
# otherwise invalidate the dependency layer on each build
|
|
ADD --chmod=755 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp /usr/local/bin/yt-dlp
|
|
|
|
COPY --chmod=755 entrypoint.sh /entrypoint.sh
|
|
COPY . .
|
|
|
|
ENV APP_HOST=0.0.0.0
|
|
ENV APP_PORT=8000
|
|
ENV TMP_DIR=/app/tmp
|
|
|
|
EXPOSE 8000
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
# Single worker to stay within Pi 3's memory budget
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
|