mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-24 23:49:41 -05:00
71 lines
3.3 KiB
Docker
71 lines
3.3 KiB
Docker
# syntax=docker/dockerfile:1.4
|
|
# GPU image (filebrowser-gpu) for linux/amd64 only.
|
|
# Final base is gtstef/ffmpeg-gpu:<ver> (Debian trixie-slim runtime). That image already
|
|
# ships ffmpeg/ffprobe in /usr/local/bin, the GPU userspace (VA-API, Vulkan, OpenCL, VPL),
|
|
# and the codec shared libraries. This file only adds the filebrowser layer.
|
|
|
|
FROM golang:trixie AS base
|
|
ARG VERSION
|
|
ARG REVISION
|
|
WORKDIR /app
|
|
COPY ./backend/go.mod ./backend/go.sum ./
|
|
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
|
COPY ./backend ./
|
|
ENV CGO_ENABLED=0
|
|
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go build -trimpath -tags analytics -ldflags="-w -s \
|
|
-X 'github.com/gtsteffaniak/filebrowser/backend/internal/version.Version=${VERSION}' \
|
|
-X 'github.com/gtsteffaniak/filebrowser/backend/internal/version.CommitSHA=${REVISION}'" \
|
|
-o filebrowser .
|
|
|
|
FROM node:slim AS nbuild
|
|
WORKDIR /build
|
|
COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
|
|
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates
|
|
RUN --mount=type=cache,target=/root/.npm cd frontend && npm ci --maxsockets 1
|
|
COPY ./frontend/ ./frontend/
|
|
WORKDIR /build/frontend
|
|
RUN npm run build:docker
|
|
|
|
FROM gtstef/ffmpeg-gpu:9.1
|
|
ENV FILEBROWSER_DATABASE_PATH="/home/filebrowser/data/database.sqlite"
|
|
ENV FILEBROWSER_CONFIG="/home/filebrowser/data/config.yaml"
|
|
ENV PATH="$PATH:/home/filebrowser"
|
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
|
ENV NVIDIA_DRIVER_CAPABILITIES=compute,video,utility,graphics
|
|
# curl is used by the healthcheck; the GPU runtime image does not ship it.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends curl \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& useradd -m -u 1000 -s /usr/sbin/nologin filebrowser
|
|
|
|
USER filebrowser
|
|
WORKDIR /home/filebrowser
|
|
|
|
COPY --from=base --chown=filebrowser:1000 [ "/app/filebrowser", "./" ]
|
|
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./data/config.yaml" ]
|
|
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./" ]
|
|
COPY --from=base --chown=filebrowser:1000 [ "/app/reduce-rounded-corners.css", "./" ]
|
|
COPY --from=nbuild --chown=filebrowser:1000 [ "/build/frontend/dist/", "./internal/web/dist/" ]
|
|
|
|
# Sanity checks: filebrowser and ffmpeg run, no missing shared libs, and the GPU
|
|
# hwaccels/encoders/filters are compiled in. Mirrors scripts/check-gpu.sh in the ffmpeg repo.
|
|
# These need no GPU device, so they run on CI runners.
|
|
RUN filebrowser version && ffmpeg -version && ffprobe -version
|
|
RUN ! ldd /usr/local/bin/ffmpeg | grep -q "not found"
|
|
RUN ldd /usr/local/bin/ffmpeg | grep -q "libva.so" && ldd /usr/local/bin/ffmpeg | grep -q "libvpl.so"
|
|
RUN ldconfig -p | grep -q libvulkan
|
|
RUN ffmpeg -hide_banner -hwaccels | grep -q vaapi \
|
|
&& ffmpeg -hide_banner -hwaccels | grep -q cuda \
|
|
&& ffmpeg -hide_banner -hwaccels | grep -q vulkan
|
|
RUN ffmpeg -hide_banner -encoders | grep -q h264_nvenc \
|
|
&& ffmpeg -hide_banner -encoders | grep -q h264_vaapi \
|
|
&& ffmpeg -hide_banner -encoders | grep -q h264_vulkan \
|
|
&& ffmpeg -hide_banner -encoders | grep -q libx264 \
|
|
&& ffmpeg -hide_banner -encoders | grep -q libvvenc
|
|
RUN ffmpeg -hide_banner -filters | grep -q scale_vulkan \
|
|
&& ffmpeg -hide_banner -filters | grep -q scale_vaapi
|
|
|
|
EXPOSE 80
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
CMD curl -f http://localhost:80/health || exit 1
|
|
ENTRYPOINT [ "./filebrowser" ]
|