mirror of
https://github.com/navidrome/navidrome.git
synced 2026-02-23 18:38:34 -05:00
* build: add sqlite_fts5 build tag to enable FTS5 support
* feat: add SearchBackend config option (default: fts)
* feat: add buildFTS5Query for safe FTS5 query preprocessing
* feat: add FTS5 search backend with config toggle, refactor legacy search
- Add searchExprFunc type and getSearchExpr() for backend selection
- Rename fullTextExpr to legacySearchExpr
- Add ftsSearchExpr using FTS5 MATCH subquery
- Update fullTextFilter in sql_restful.go to use configured backend
* feat: add FTS5 migration with virtual tables, triggers, and search_participants
Creates FTS5 virtual tables for media_file, album, and artist with
unicode61 tokenizer and diacritic folding. Adds search_participants
column, populates from JSON, and sets up INSERT/UPDATE/DELETE triggers.
* feat: populate search_participants in PostMapArgs for FTS5 indexing
* test: add FTS5 search integration tests
* fix: exclude FTS5 virtual tables from e2e DB restore
The restoreDB function iterates all tables in sqlite_master and
runs DELETE + INSERT to reset state. FTS5 contentless virtual tables
cannot be directly deleted from. Since triggers handle FTS5 sync
automatically, simply skip tables matching *_fts and *_fts_* patterns.
* build: add compile-time guard for sqlite_fts5 build tag
Same pattern as netgo: compilation fails with a clear error if
the sqlite_fts5 build tag is missing.
* build: add sqlite_fts5 tag to reflex dev server config
* build: extract GO_BUILD_TAGS variable in Makefile to avoid duplication
* fix: strip leading * from FTS5 queries to prevent "unknown special query" error
* feat: auto-append prefix wildcard to FTS5 search tokens for broader matching
Every plain search token now gets a trailing * appended (e.g., "love" becomes
"love*"), so searching for "love" also matches "lovelace", "lovely", etc.
Quoted phrases are preserved as exact matches without wildcards. Results are
ordered alphabetically by name/title, so shorter exact matches naturally
appear first.
* fix: clarify comments about FTS5 operator neutralization
The comments said "strip" but the code lowercases operators to
neutralize them (FTS5 operators are case-sensitive). Updated comments
to accurately describe the behavior.
* fix: use fmt.Sprintf for FTS5 phrase placeholders
The previous encoding used rune('0'+index) which silently breaks with
10+ quoted phrases. Use fmt.Sprintf for arbitrary index support.
* fix: validate and normalize SearchBackend config option
Normalize the value to lowercase and fall back to "fts" with a log
warning for unrecognized values. This prevents silent misconfiguration
from typos like "FTS", "Legacy", or "fts5".
* refactor: improve documentation for build tags and FTS5 requirements
Signed-off-by: Deluan <deluan@navidrome.org>
* refactor: convert FTS5 query and search backend normalization tests to DescribeTable format
Signed-off-by: Deluan <deluan@navidrome.org>
* fix: add sqlite_fts5 build tag to golangci configuration
Signed-off-by: Deluan <deluan@navidrome.org>
* feat: add UISearchDebounceMs configuration option and update related components
Signed-off-by: Deluan <deluan@navidrome.org>
* fix: fall back to legacy search when SearchFullString is enabled
FTS5 is token-based and cannot match substrings within words, so
getSearchExpr now returns legacySearchExpr when SearchFullString
is true, regardless of SearchBackend setting.
* fix: add sqlite_fts5 build tag to CI pipeline and Dockerfile
* fix: add WHEN clauses to FTS5 AFTER UPDATE triggers
Added WHEN clauses to the media_file_fts_au, album_fts_au, and
artist_fts_au triggers so they only fire when FTS-indexed columns
actually change. Previously, every row update (e.g., play count, rating,
starred status) triggered an unnecessary delete+insert cycle in the FTS
shadow tables. The WHEN clauses use IS NOT for NULL-safe comparison of
each indexed column, avoiding FTS index churn for non-indexed updates.
* feat: add SearchBackend configuration option to data and insights components
Signed-off-by: Deluan <deluan@navidrome.org>
* fix: enhance input sanitization for FTS5 by stripping additional punctuation and special characters
Signed-off-by: Deluan <deluan@navidrome.org>
* feat: add search_normalized column for punctuated name search (R.E.M., AC/DC)
Add index-time normalization and query-time single-letter collapsing to
fix FTS5 search for punctuated names. A new search_normalized column
stores concatenated forms of punctuated words (e.g., "R.E.M." → "REM",
"AC/DC" → "ACDC") and is indexed in FTS5 tables. At query time, runs of
consecutive single letters (from dot-stripping) are collapsed into OR
expressions like ("R E M" OR REM*) to match both the original tokens and
the normalized form. This enables searching by "R.E.M.", "REM", "AC/DC",
"ACDC", "A-ha", or "Aha" and finding the correct results.
* refactor: simplify isSingleUnicodeLetter to avoid []rune allocation
Use utf8.DecodeRuneInString to check for a single Unicode letter
instead of converting the entire string to a []rune slice.
* feat: define ftsSearchColumns for flexible FTS5 search column inclusion
Signed-off-by: Deluan <deluan@navidrome.org>
* feat: update collapseSingleLetterRuns to return quoted phrases for abbreviations
Signed-off-by: Deluan <deluan@navidrome.org>
* feat: implement extractPunctuatedWords to handle artist/album names with embedded punctuation
Signed-off-by: Deluan <deluan@navidrome.org>
* feat: implement extractPunctuatedWords to handle artist/album names with embedded punctuation
Signed-off-by: Deluan <deluan@navidrome.org>
* refactor: punctuated word handling to improve processing of artist/album names
Signed-off-by: Deluan <deluan@navidrome.org>
* feat: add CJK support for search queries with LIKE filters
Signed-off-by: Deluan <deluan@navidrome.org>
* feat: enhance FTS5 search by adding album version support and CJK handling
Signed-off-by: Deluan <deluan@navidrome.org>
* refactor: search configuration to use structured options
Signed-off-by: Deluan <deluan@navidrome.org>
* feat: enhance search functionality to support punctuation-only queries and update related tests
Signed-off-by: Deluan <deluan@navidrome.org>
---------
Signed-off-by: Deluan <deluan@navidrome.org>
148 lines
4.6 KiB
Docker
148 lines
4.6 KiB
Docker
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/
|
|
|
|
########################################################################################################################
|
|
### Get TagLib
|
|
FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/alpine:3.20 AS taglib-build
|
|
ARG TARGETPLATFORM
|
|
ARG CROSS_TAGLIB_VERSION=2.2.0-1
|
|
ENV CROSS_TAGLIB_RELEASES_URL=https://github.com/navidrome/cross-taglib/releases/download/v${CROSS_TAGLIB_VERSION}/
|
|
|
|
# wget in busybox can't follow redirects
|
|
RUN <<EOT
|
|
apk add --no-cache wget
|
|
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.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 \
|
|
--mount=from=taglib-build,target=/taglib,src=/taglib,ro <<EOT
|
|
|
|
# Setup CGO cross-compilation environment
|
|
xx-go --wrap
|
|
export CGO_ENABLED=1
|
|
export CGO_CFLAGS_ALLOW="--define-prefix"
|
|
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,sqlite_fts5 -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.20 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
|
|
RUN touch /.nddockerenv
|
|
|
|
EXPOSE ${ND_PORT}
|
|
WORKDIR /app
|
|
|
|
ENTRYPOINT ["/app/navidrome"]
|
|
|