Dockerfile 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # DESIGNED FOR BUILDING ON AMD64 ONLY
  2. #####################################
  3. # Requires binfm_misc registration
  4. # https://github.com/multiarch/qemu-user-static#binfmt_misc-register
  5. ARG DOTNET_VERSION=6.0
  6. FROM node:lts-alpine as web-builder
  7. ARG JELLYFIN_WEB_VERSION=master
  8. RUN apk add curl git zlib zlib-dev autoconf g++ make libpng-dev gifsicle alpine-sdk automake libtool make gcc musl-dev nasm python3 \
  9. && curl -L https://github.com/jellyfin/jellyfin-web/archive/${JELLYFIN_WEB_VERSION}.tar.gz | tar zxf - \
  10. && cd jellyfin-web-* \
  11. && npm ci --no-audit --unsafe-perm \
  12. && mv dist /dist
  13. FROM debian:stable-slim as app
  14. # https://askubuntu.com/questions/972516/debian-frontend-environment-variable
  15. ARG DEBIAN_FRONTEND="noninteractive"
  16. # http://stackoverflow.com/questions/48162574/ddg#49462622
  17. ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
  18. # https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(Native-GPU-Support)
  19. ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
  20. # https://github.com/intel/compute-runtime/releases
  21. ARG GMMLIB_VERSION=22.0.2
  22. ARG IGC_VERSION=1.0.10395
  23. ARG NEO_VERSION=22.08.22549
  24. ARG LEVEL_ZERO_VERSION=1.3.22549
  25. # Install dependencies:
  26. # mesa-va-drivers: needed for AMD VAAPI. Mesa >= 20.1 is required for HEVC transcoding.
  27. # curl: healthcheck
  28. RUN apt-get update \
  29. && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates gnupg wget apt-transport-https curl \
  30. && wget -O - https://repo.jellyfin.org/jellyfin_team.gpg.key | apt-key add - \
  31. && echo "deb [arch=$( dpkg --print-architecture )] https://repo.jellyfin.org/$( awk -F'=' '/^ID=/{ print $NF }' /etc/os-release ) $( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release ) main" | tee /etc/apt/sources.list.d/jellyfin.list \
  32. && apt-get update \
  33. && apt-get install --no-install-recommends --no-install-suggests -y \
  34. mesa-va-drivers \
  35. jellyfin-ffmpeg \
  36. openssl \
  37. locales \
  38. # Intel VAAPI Tone mapping dependencies:
  39. # Prefer NEO to Beignet since the latter one doesn't support Comet Lake or newer for now.
  40. # Do not use the intel-opencl-icd package from repo since they will not build with RELEASE_WITH_REGKEYS enabled.
  41. && mkdir intel-compute-runtime \
  42. && cd intel-compute-runtime \
  43. && wget https://github.com/intel/compute-runtime/releases/download/${NEO_VERSION}/intel-gmmlib_${GMMLIB_VERSION}_amd64.deb \
  44. && wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-${IGC_VERSION}/intel-igc-core_${IGC_VERSION}_amd64.deb \
  45. && wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-${IGC_VERSION}/intel-igc-opencl_${IGC_VERSION}_amd64.deb \
  46. && wget https://github.com/intel/compute-runtime/releases/download/${NEO_VERSION}/intel-opencl-icd_${NEO_VERSION}_amd64.deb \
  47. && wget https://github.com/intel/compute-runtime/releases/download/${NEO_VERSION}/intel-level-zero-gpu_${LEVEL_ZERO_VERSION}_amd64.deb \
  48. && dpkg -i *.deb \
  49. && cd .. \
  50. && rm -rf intel-compute-runtime \
  51. && apt-get remove gnupg wget apt-transport-https -y \
  52. && apt-get clean autoclean -y \
  53. && apt-get autoremove -y \
  54. && rm -rf /var/lib/apt/lists/* \
  55. && mkdir -p /cache /config /media \
  56. && chmod 777 /cache /config /media \
  57. && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
  58. # ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
  59. ENV LC_ALL en_US.UTF-8
  60. ENV LANG en_US.UTF-8
  61. ENV LANGUAGE en_US:en
  62. FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} as builder
  63. WORKDIR /repo
  64. COPY . .
  65. ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
  66. # because of changes in docker and systemd we need to not build in parallel at the moment
  67. # see https://success.docker.com/article/how-to-reserve-resource-temporarily-unavailable-errors-due-to-tasksmax-setting
  68. RUN dotnet publish Jellyfin.Server --disable-parallel --configuration Release --output="/jellyfin" --self-contained --runtime linux-x64 -p:DebugSymbols=false -p:DebugType=none
  69. FROM app
  70. ENV HEALTHCHECK_URL=http://localhost:8096/health
  71. COPY --from=builder /jellyfin /jellyfin
  72. COPY --from=web-builder /dist /jellyfin/jellyfin-web
  73. EXPOSE 8096
  74. VOLUME /cache /config
  75. ENTRYPOINT ["./jellyfin/jellyfin", \
  76. "--datadir", "/config", \
  77. "--cachedir", "/cache", \
  78. "--ffmpeg", "/usr/lib/jellyfin-ffmpeg/ffmpeg"]
  79. HEALTHCHECK --interval=30s --timeout=30s --start-period=10s --retries=3 \
  80. CMD curl -Lk "${HEALTHCHECK_URL}" || exit 1