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 FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/golang:1.25-trixie AS base RUN apt-get update && apt-get install -y clang lld COPY --from=xx / / WORKDIR /workspace FROM --platform=$BUILDPLATFORM base AS build # Install build dependencies for the target platform ARG TARGETPLATFORM RUN xx-apt install -y binutils gcc g++ libc6-dev zlib1g-dev RUN xx-verify --setup 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=from=osxcross,src=/osxcross/SDK,target=/xx-sdk,ro \ --mount=type=cache,target=/root/.cache \ --mount=type=cache,target=/go/pkg/mod <