fix(ci): pre-build .NET on host runner, remove SDK from Docker build
DinD overlay-on-overlay throttles dotnet child container to ~11s CPU/3h wall time. Solution: dotnet restore+publish run on native runner FS (~10min), then Dockerfile.runtime just COPYs the pre-built publish-output/ directory. This brings build time from 3h+ (stuck) to ~10-15 minutes total.
This commit is contained in:
@@ -37,6 +37,34 @@ jobs:
|
||||
echo "image_repo=${REPO}" >> "$GITHUB_OUTPUT"
|
||||
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Install .NET SDK
|
||||
# Build on the runner host filesystem (native I/O) to avoid DinD
|
||||
# overlay-on-overlay throttling which makes dotnet publish ~20x slower.
|
||||
run: |
|
||||
DOTNET_INSTALL_DIR="$HOME/.dotnet"
|
||||
mkdir -p "$DOTNET_INSTALL_DIR"
|
||||
if ! "$DOTNET_INSTALL_DIR/dotnet" --version 2>/dev/null | grep -q "^10\\."; then
|
||||
curl -fsSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 10.0 --install-dir "$DOTNET_INSTALL_DIR"
|
||||
fi
|
||||
echo "DOTNET_ROOT=$DOTNET_INSTALL_DIR" >> "$GITHUB_ENV"
|
||||
echo "PATH=$DOTNET_INSTALL_DIR:$PATH" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Restore NuGet packages
|
||||
run: |
|
||||
export PATH="$HOME/.dotnet:$PATH"
|
||||
dotnet restore Jellyfin.Server/Jellyfin.Server.csproj --runtime linux-x64
|
||||
|
||||
- name: Publish Jellyfin server
|
||||
run: |
|
||||
export PATH="$HOME/.dotnet:$PATH"
|
||||
dotnet publish Jellyfin.Server/Jellyfin.Server.csproj \
|
||||
--configuration Release \
|
||||
--runtime linux-x64 \
|
||||
--self-contained false \
|
||||
--no-restore \
|
||||
-p:TreatWarningsAsErrors=false \
|
||||
--output ./publish-output
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
@@ -44,7 +72,7 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
file: Dockerfile.runtime
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
provenance: false
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Runtime-only image — the .NET publish step runs on the CI host (runner),
|
||||
# not inside this Dockerfile. This avoids DinD overlay-on-overlay I/O throttling
|
||||
# which makes `dotnet publish` inside Docker-in-Docker prohibitively slow on k3s.
|
||||
|
||||
FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/aspnet:10.0
|
||||
|
||||
# Install FFmpeg and native dependencies required by SkiaSharp and fontconfig.
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ffmpeg \
|
||||
fontconfig \
|
||||
libfontconfig1 \
|
||||
libfreetype6 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /jellyfin
|
||||
|
||||
# Copy the pre-built publish output produced by `dotnet publish` on the CI host.
|
||||
COPY publish-output/ .
|
||||
|
||||
# Jellyfin default ports
|
||||
EXPOSE 8096
|
||||
EXPOSE 8920
|
||||
|
||||
# Data / config volumes
|
||||
VOLUME ["/config", "/cache", "/media"]
|
||||
|
||||
ENV JELLYFIN_DATA_DIR=/config \
|
||||
JELLYFIN_CACHE_DIR=/cache \
|
||||
JELLYFIN_LOG_DIR=/config/log \
|
||||
JELLYFIN_CONFIG_DIR=/config
|
||||
|
||||
ENTRYPOINT ["./jellyfin", \
|
||||
"--datadir", "/config", \
|
||||
"--cachedir", "/cache"]
|
||||
Reference in New Issue
Block a user