Files
Patryk GenschandClaude Opus 5 20ce26364c Add relocate, and a CUDA image for transcribing on an NVIDIA box
The database records absolute paths to the disc images, because audio, animation
frames and transcription all read straight out of them. Carrying catalog.sqlite
to another machine therefore leaves a catalogue that displays everything and can
play nothing — and the same already applied between host and container, where the
collection is /Users/... on one side and /media on the other.

`relocate <directory>` re-points every copy, matching on filename and confirming
by size, with --verify adding a full SHA-256 and --dry-run showing the outcome
first. Copies that cannot be matched keep their old path and are reported rather
than quietly rewritten.

Names are compared after Unicode normalisation, which turned out to be the whole
problem in practice: macOS stores "Wojna Trojańska.iso" decomposed (n + combining
acute) while the database held it composed. Two of thirteen copies failed to match
until that was fixed — and the same mismatch is exactly what would happen carrying
a collection between macOS and Windows.

Verified by rewriting the paths in a copy of the database to a Windows-shaped
D:\Kolekcja, relocating, and then reading a voice line and an animation frame out
of the discs through the relocated database.

Dockerfile.cuda builds whisper.cpp with GGML_CUDA for compute capability 8.6
(GeForce RTX 30), on nvidia/cuda for both stages, with the JRE installed on top of
the CUDA runtime. It is a separate file because both base images differ; folding it
into the main Dockerfile would be more conditionals than content. Not verified
beyond `docker build --check`: there is no NVIDIA GPU here, and the images are
amd64.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 17:10:36 +02:00

77 lines
3.2 KiB
Docker

# Wariant pod NVIDIĘ — do transkrypcji na maszynie z kartą.
#
# Osobny plik, a nie przełącznik w Dockerfile, bo różnią się obrazy bazowe obu
# etapów: whisper.cpp trzeba zbudować przy toolkicie CUDA, a obraz uruchomieniowy
# musi nieść biblioteki CUDA i dopiero do nich dołożyć JRE. Wciśnięcie tego w
# jeden plik dałoby więcej warunków niż treści.
#
# Budowanie i uruchomienie (wymaga NVIDIA Container Toolkit po stronie hosta;
# na Windowsie: Docker Desktop z WSL2):
# docker build -f Dockerfile.cuda -t rex-catalog:cuda .
# docker run --rm --gpus all -v D:\Reksio:/media:ro -v katalog:/data \
# -v D:\modele:/models:ro -e WHISPER_MODEL=/models/ggml-medium.bin \
# rex-catalog:cuda transcribe
#
# Po przeniesieniu bazy z innej maszyny najpierw przypnij ją do kolekcji:
# docker run --rm -v D:\Reksio:/media:ro -v katalog:/data rex-catalog:cuda relocate /media
FROM eclipse-temurin:21-jdk AS build
WORKDIR /src
COPY gradlew settings.gradle build.gradle gradle.properties ./
COPY gradle ./gradle
COPY vendor ./vendor
RUN ./gradlew --no-daemon dependencies --configuration runtimeClasspath > /dev/null 2>&1 || true
COPY src ./src
RUN ./gradlew --no-daemon installDist \
&& grep '^coreVersion=' gradle.properties | cut -d= -f2 > /src/core-version
# CMAKE_CUDA_ARCHITECTURES=86 to Ampere z GeForce RTX 30 (3060 ma 8.6).
# Budowanie pod wszystkie architektury trwa wielokrotnie dłużej i puchnie,
# a i tak nie przyda się na innej karcie bez przebudowy.
FROM nvidia/cuda:12.6.2-devel-ubuntu24.04 AS whisper
ARG CUDA_ARCH=86
RUN apt-get update \
&& apt-get install -y --no-install-recommends git cmake build-essential ca-certificates \
&& git clone --depth 1 --branch v1.9.2 https://github.com/ggerganov/whisper.cpp /src \
&& cmake -S /src -B /src/build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON \
-DGGML_NATIVE=OFF -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCH} \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=ON \
&& cmake --build /src/build --target whisper-cli -j "$(nproc)" \
&& mkdir -p /out/bin /out/lib \
&& cp /src/build/bin/whisper-cli /out/bin/ \
&& find /src/build \( -name 'libwhisper.so*' -o -name 'libggml*.so*' \) \
-exec cp -P {} /out/lib/ \; \
&& rm -rf /var/lib/apt/lists/* /src
FROM nvidia/cuda:12.6.2-runtime-ubuntu24.04
WORKDIR /app
VOLUME ["/data"]
ENV CATALOG_DATA=/data
ENV WHISPER_BIN=/usr/local/bin/whisper-cli
# JRE z repozytoriów, bo obraz bazowy niesie CUDA, a nie Javę; ffmpeg do
# przepróbkowania nagrań na 16 kHz mono, których whisper.cpp wymaga
RUN apt-get update \
&& apt-get install -y --no-install-recommends openjdk-21-jre-headless ffmpeg \
&& rm -rf /var/lib/apt/lists/*
COPY --from=whisper /out/bin/whisper-cli /usr/local/bin/whisper-cli
COPY --from=whisper /out/lib/ /usr/local/lib/
RUN ldconfig
COPY --from=build /src/build/install/rex-catalog /app
COPY --from=build /src/core-version /app/core-version
COPY docker-entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh \
&& useradd --uid 10001 --create-home katalog \
&& mkdir -p /data /media \
&& chown katalog:katalog /data
USER katalog
EXPOSE 8765
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["serve", "--host", "0.0.0.0"]