mirror of
https://github.com/navidrome/navidrome.git
synced 2025-07-13 15:11:27 +03:00
* chore: update CROSS_TAGLIB_VERSION to 2.1.1-1 * feat: add run-docker target Introduced a new Makefile target `run-docker` that allows users to run a Navidrome Docker image with specified tags. This addition simplifies the process of launching the Docker container by handling volume mappings for configuration and music folders. The change enhances the development workflow by making it easier to test and run PR images Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
146 lines
4.5 KiB
Docker
146 lines
4.5 KiB
Docker
FROM --platform=$BUILDPLATFORM ghcr.io/crazy-max/osxcross:14.5-debian AS osxcross
|
|
|
|
########################################################################################################################
|
|
### Build xx (orignal image: tonistiigi/xx)
|
|
FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/alpine:3.19 AS xx-build
|
|
|
|
# v1.5.0
|
|
ENV XX_VERSION=b4e4c451c778822e6742bfc9d9a91d7c7d885c8a
|
|
|
|
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/
|
|
|
|
########################################################################################################################
|
|
### Get TagLib
|
|
FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/alpine:3.19 AS taglib-build
|
|
ARG TARGETPLATFORM
|
|
ARG CROSS_TAGLIB_VERSION=2.1.1-1
|
|
ENV CROSS_TAGLIB_RELEASES_URL=https://github.com/navidrome/cross-taglib/releases/download/v${CROSS_TAGLIB_VERSION}/
|
|
|
|
RUN <<EOT
|
|
PLATFORM=$(echo ${TARGETPLATFORM} | tr '/' '-')
|
|
FILE=taglib-${PLATFORM}.tar.gz
|
|
|
|
DOWNLOAD_URL=${CROSS_TAGLIB_RELEASES_URL}${FILE}
|
|
wget ${DOWNLOAD_URL}
|
|
|
|
mkdir /taglib
|
|
tar -xzf ${FILE} -C /taglib
|
|
EOT
|
|
|
|
########################################################################################################################
|
|
### 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.24-bookworm 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 \
|
|
--mount=from=taglib-build,target=/taglib,src=/taglib,ro <<EOT
|
|
|
|
# Setup CGO cross-compilation environment
|
|
xx-go --wrap
|
|
export CGO_ENABLED=1
|
|
export PKG_CONFIG_PATH=/taglib/lib/pkgconfig
|
|
cat $(go env GOENV)
|
|
|
|
# Only Darwin (macOS) requires clang (default), Windows requires gcc, everything else can use any compiler.
|
|
# So let's use gcc for everything except Darwin.
|
|
if [ "$(xx-info os)" != "darwin" ]; then
|
|
export CC=$(xx-info)-gcc
|
|
export CXX=$(xx-info)-g++
|
|
export LD_EXTRA="-extldflags '-static -latomic'"
|
|
fi
|
|
if [ "$(xx-info os)" = "windows" ]; then
|
|
export EXT=".exe"
|
|
fi
|
|
|
|
go build -tags=netgo -ldflags="${LD_EXTRA} -w -s \
|
|
-X github.com/navidrome/navidrome/consts.gitSha=${GIT_SHA} \
|
|
-X github.com/navidrome/navidrome/consts.gitTag=${GIT_TAG}" \
|
|
-o /out/navidrome${EXT} .
|
|
EOT
|
|
|
|
# Verify if the binary was built for the correct platform and it is statically linked
|
|
RUN xx-verify --static /out/navidrome*
|
|
|
|
FROM scratch AS binary
|
|
COPY --from=build /out /
|
|
|
|
########################################################################################################################
|
|
### Build Final Image
|
|
FROM public.ecr.aws/docker/library/alpine:3.19 AS final
|
|
LABEL maintainer="deluan@navidrome.org"
|
|
LABEL org.opencontainers.image.source="https://github.com/navidrome/navidrome"
|
|
|
|
# Install ffmpeg and mpv
|
|
RUN apk add -U --no-cache ffmpeg mpv sqlite
|
|
|
|
# Copy navidrome binary
|
|
COPY --from=build /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 GODEBUG="asyncpreemptoff=1"
|
|
RUN touch /.nddockerenv
|
|
|
|
EXPOSE ${ND_PORT}
|
|
WORKDIR /app
|
|
|
|
ENTRYPOINT ["/app/navidrome"]
|
|
|