🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
feat(artwork): enable native libwebp encoding in Docker image (#5350)
Deluan Quintãoe53e60d39da2
diff --git a/Dockerfile b/Dockerfileindex f6ea14ff3..66243f84c 100644--- a/Dockerfile+++ b/Dockerfile@@ -42,7 +42,46 @@ FROM scratch AS ui-bundleCOPY --from=ui /build /build########################################################################################################################-### Build Navidrome binary+### Build Navidrome binary for Docker image (dynamic musl, enables native libwebp via dlopen)+FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/golang:1.25-alpine AS build-alpine+COPY --from=xx / /++ARG TARGETPLATFORM++RUN apk add --no-cache clang lld file git+RUN xx-apk add --no-cache gcc musl-dev zlib-dev+RUN xx-verify --setup++WORKDIR /workspace++RUN --mount=type=bind,source=. \+ --mount=type=cache,target=/root/.cache \+ --mount=type=cache,target=/go/pkg/mod \+ go mod download++ARG GIT_SHA+ARG GIT_TAG++RUN --mount=type=bind,source=. \+ --mount=from=ui,source=/build,target=./ui/build,ro \+ --mount=type=cache,target=/root/.cache \+ --mount=type=cache,target=/go/pkg/mod <<EOT+ set -e+ xx-go --wrap+ export CGO_ENABLED=1+ # -latomic is required on 32-bit arm (arm/v6, arm/v7) so SQLite's 64-bit atomics resolve.+ go build -tags=netgo,sqlite_fts5 -ldflags="-w -s \+ -linkmode=external -extldflags '-latomic' \+ -X github.com/navidrome/navidrome/consts.gitSha=${GIT_SHA} \+ -X github.com/navidrome/navidrome/consts.gitTag=${GIT_TAG}" \+ -o /out/navidrome .+ # Fail the build if the binary is accidentally statically linked: dlopen (and+ # therefore native libwebp detection) only works with a dynamic interpreter.+ file /out/navidrome | grep -q "dynamically linked" || { echo "ERROR: /out/navidrome is not dynamically linked"; file /out/navidrome; exit 1; }+EOT++########################################################################################################################+### Build Navidrome binary for standalone distribution (static glibc, cross-compiled)FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/golang:1.25-trixie AS baseRUN apt-get update && apt-get install -y clang lldCOPY --from=xx / /@@ -104,17 +143,23 @@ FROM public.ecr.aws/docker/library/alpine:3.20 AS finalLABEL maintainer="[email protected]"LABEL org.opencontainers.image.source="https://github.com/navidrome/navidrome"-# Install ffmpeg and mpv-RUN apk add -U --no-cache ffmpeg mpv sqlite+# Install runtime dependencies+# - libwebp + symlinks: enables native WebP encoding via purego/dlopen+RUN apk add -U --no-cache ffmpeg mpv sqlite libwebp libwebpdemux libwebpmux && \+ for lib in libwebp libwebpdemux libwebpmux; do \+ target=$(ls /usr/lib/$lib.so.* 2>/dev/null | head -1) && \+ [ -n "$target" ] && ln -sf "$target" /usr/lib/$lib.so; \+ done-# Copy navidrome binary-COPY --from=build /out/navidrome /app/+# Copy navidrome binary (musl build for Docker, enables native libwebp)+COPY --from=build-alpine /out/navidrome /app/VOLUME ["/data", "/music"]ENV ND_MUSICFOLDER=/musicENV ND_DATAFOLDER=/dataENV ND_CONFIGFILE=/data/navidrome.tomlENV ND_PORT=4533+ENV ND_ENABLEWEBPENCODING=trueRUN touch /.nddockerenvEXPOSE ${ND_PORT}