FROM --platform=$BUILDPLATFORM ghcr.io/crazy-max/osxcross:14.5-debian AS osxcross ######################################################################################################################## ### Build xx (original image: tonistiigi/xx) FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/alpine:3.20 AS xx-build # v1.9.0 ENV XX_VERSION=a5592eab7a57895e8d385394ff12241bc65ecd50 RUN apk add -U --no-cache git RUN git clone https://github.com/tonistiigi/xx && \ cd xx && \ git checkout ${XX_VERSION} && \ mkdir -p /out && \ cp src/xx-* /out/ RUN cd /out && \ ln -s xx-cc /out/xx-clang && \ ln -s xx-cc /out/xx-clang++ && \ ln -s xx-cc /out/xx-c++ && \ ln -s xx-apt /out/xx-apt-get # xx mimics the original tonistiigi/xx image FROM scratch AS xx COPY --from=xx-build /out/ /usr/bin/ ######################################################################################################################## ### Build Navidrome UI FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/node:lts-alpine AS ui WORKDIR /app # Install node dependencies COPY ui/package.json ui/package-lock.json ./ COPY ui/bin/ ./bin/ RUN npm ci # Build bundle COPY ui/ ./ RUN npm run build -- --outDir=/build FROM scratch AS ui-bundle COPY --from=ui /build /build ######################################################################################################################## ### Build Navidrome binary for Docker image (dynamic musl, enables native libwebp via dlopen) FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/golang:1.26-alpine AS build-alpine COPY --from=xx / / ARG TARGETPLATFORM RUN apk add --no-cache clang lld 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 </dev/null | head -1) && \ [ -n "$target" ] && ln -sf "$target" /usr/lib/$lib.so; \ done # Copy navidrome binary (musl build for Docker, enables native libwebp) COPY --from=build-alpine /out/navidrome /app/ VOLUME ["/data", "/music"] ENV ND_MUSICFOLDER=/music ENV ND_DATAFOLDER=/data ENV ND_CONFIGFILE=/data/navidrome.toml ENV ND_PORT=4533 ENV ND_ENABLEWEBPENCODING=true RUN touch /.nddockerenv EXPOSE ${ND_PORT} WORKDIR /app ENTRYPOINT ["/app/navidrome"]