navidrome/Dockerfile

58 lines
1.8 KiB
Docker
Raw Normal View History

2020-01-23 01:42:56 +01:00
#####################################################
### Build UI bundles
2020-01-24 00:31:52 +01:00
FROM node:13.7-alpine AS jsbuilder
2020-01-23 01:42:56 +01:00
WORKDIR /src
COPY ui/package.json ui/package-lock.json ./
RUN npm ci
COPY ui/ .
RUN npm run build
#####################################################
### Build executable
FROM golang:1.13-alpine AS gobuilder
# Download build tools
RUN mkdir -p /src/ui/build
RUN apk add -U --no-cache build-base git
RUN go get -u github.com/go-bindata/go-bindata/...
2020-01-25 17:06:04 +01:00
# Download and unpack static ffmpeg
ARG FFMPEG_VERSION=4.1.4
ARG FFMPEG_URL=https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar.xz
RUN wget -O /tmp/ffmpeg.tar.xz ${FFMPEG_URL}
RUN cd /tmp && tar xJf ffmpeg.tar.xz && rm ffmpeg.tar.xz
2020-01-23 01:42:56 +01:00
# Download project dependencies
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
# Copy source and UI bundle, build executable
COPY . .
COPY --from=jsbuilder /src/build/* /src/ui/build/
COPY --from=jsbuilder /src/build/static/css/* /src/ui/build/static/css/
COPY --from=jsbuilder /src/build/static/js/* /src/ui/build/static/js/
RUN rm -rf /src/build/css /src/build/js
RUN GIT_SHA=$(git rev-parse --short HEAD) && \
GIT_TAG=$(git describe --tags --abbrev=0 2> /dev/null) && \
go-bindata -fs -prefix ui/build -tags embed -nocompress -pkg assets -o assets/embedded_gen.go ui/build/... && \
go build -ldflags="-X main.gitSha=${GIT_SHA} -X main.gitTag=${GIT_TAG}" -tags=embed
2020-01-23 01:42:56 +01:00
#####################################################
### Build Final Image
FROM alpine
2020-01-24 01:44:08 +01:00
COPY --from=gobuilder /src/navidrome /app/
2020-01-23 01:42:56 +01:00
COPY --from=gobuilder /tmp/ffmpeg*/ffmpeg /usr/bin/
VOLUME ["/data", "/music"]
2020-01-24 07:29:31 +01:00
ENV ND_MUSICFOLDER /music
ENV ND_DATAFOLDER /data
ENV ND_SCANINTERVAL 1m
2020-01-24 07:29:31 +01:00
ENV ND_LOGLEVEL info
ENV ND_PORT 4533
2020-01-23 01:42:56 +01:00
EXPOSE 4533
WORKDIR /app
2020-01-24 01:44:08 +01:00
CMD "/app/navidrome"