# NoMercy MediaServer Dockerfile - NVIDIA GPU Support # Includes CUDA runtime and NVENC/NVDEC libraries for hardware acceleration # # FFmpeg is downloaded by the MediaServer at runtime with NVENC/NVDEC support. # This image provides the necessary NVIDIA libraries. # ============================================================================= # Stage 1: Build # ============================================================================= FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /src # Copy source and restore dependencies COPY NoMercy.Server.sln ./ COPY src/ src/ COPY assets/ assets/ RUN dotnet restore src/NoMercy.Service/NoMercy.Service.csproj # Build and publish RUN dotnet publish src/NoMercy.Service/NoMercy.Service.csproj \ -c Release \ -o /app/publish \ --no-restore \ -p:PublishSingleFile=false \ -p:DebugType=None \ -p:DebugSymbols=false # ============================================================================= # Stage 2: Runtime with NVIDIA CUDA libraries # ============================================================================= FROM nvidia/cuda:12.3.1-runtime-ubuntu22.04 AS runtime WORKDIR /app # Install .NET 10.0 runtime and NVIDIA codec libraries RUN apt-get update && apt-get install -y --no-install-recommends \ # .NET dependencies ca-certificates \ libc6 \ libgcc-s1 \ libicu70 \ libssl3 \ libstdc++6 \ zlib1g \ wget \ # NVIDIA Video Codec SDK libraries (for NVENC/NVDEC) libnvidia-encode-535 \ libnvidia-decode-535 \ # CUDA libraries for video processing libcudart12 \ libnpp12 \ # Media info mediainfo \ curl \ sqlite3 \ htop \ nvtop \ && rm -rf /var/lib/apt/lists/* # Install .NET 10.0 ASP.NET runtime RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \ && chmod +x dotnet-install.sh \ && ./dotnet-install.sh --channel 10.0 --runtime aspnetcore --install-dir /usr/share/dotnet \ && rm dotnet-install.sh \ && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet # Create non-root user for security RUN useradd -m -o -u 1000 nomercy # Create data directories RUN mkdir -p /data/config /data/cache /data/media /data/log \ && chown -R nomercy:nomercy /data # Copy published application COPY --from=build /app/publish . # Set ownership RUN chown -R nomercy:nomercy /app # Switch to non-root user USER nomercy # Environment variables ENV ASPNETCORE_ENVIRONMENT=Production ENV DOTNET_RUNNING_IN_CONTAINER=true ENV HOME=/data ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 # NVIDIA environment variables ENV NVIDIA_VISIBLE_DEVICES=all ENV NVIDIA_DRIVER_CAPABILITIES=compute,video,utility # Expose port EXPOSE 7626 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -fsk https://127.0.0.1:7626/health || curl -fs http://127.0.0.1:7626/health || exit 1 # Entry point ENTRYPOINT ["dotnet", "NoMercyMediaServer.dll"] CMD ["--internal-port", "7626"]