Simplify Dockerfiles: use dotnet nuget add source API

Replaced manual NuGet.Config creation with simple API call:
- Applied to both Host and Migrator Dockerfiles
- Reduced from 20+ lines to 1 line per config
- No API key needed for public read access

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ruberoid 2025-10-14 15:00:19 +04:00
parent f6d1b103d1
commit 5045e0826e
2 changed files with 6 additions and 36 deletions

View File

@ -16,25 +16,10 @@ RUN apt-get update && \
COPY . .
# Create NuGet.Config with package source mapping to avoid NU1507 warnings
RUN mkdir -p /root/.nuget/NuGet && \
echo '<?xml version="1.0" encoding="utf-8"?>' > /root/.nuget/NuGet/NuGet.Config && \
echo '<configuration>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <packageSources>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <add key="musk.fun.nocr" value="https://gitea.musk.fun/api/packages/nocr/nuget/index.json" />' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' </packageSources>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <packageSourceMapping>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <packageSource key="musk.fun.nocr">' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <package pattern="Nocr.*" />' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' </packageSource>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <packageSource key="nuget.org">' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <package pattern="*" />' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' </packageSource>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' </packageSourceMapping>' >> /root/.nuget/NuGet/NuGet.Config && \
echo '</configuration>' >> /root/.nuget/NuGet/NuGet.Config
# Add custom NuGet source (no API key needed for public read access)
RUN dotnet nuget add source https://gitea.musk.fun/api/packages/nocr/nuget/index.json --name musk
# Restore with verbose logging to see what's happening
# Restore with verbose logging
RUN dotnet restore "src/Nocr.TextMatcher.Host/Nocr.TextMatcher.Host.csproj" --verbosity normal
WORKDIR "/src/src/Nocr.TextMatcher.Host"
RUN dotnet build "Nocr.TextMatcher.Host.csproj" -c Release -o /app/build

View File

@ -15,25 +15,10 @@ RUN apt-get update && \
COPY . .
# Create NuGet.Config with package source mapping to avoid NU1507 warnings
RUN mkdir -p /root/.nuget/NuGet && \
echo '<?xml version="1.0" encoding="utf-8"?>' > /root/.nuget/NuGet/NuGet.Config && \
echo '<configuration>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <packageSources>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <add key="musk.fun.nocr" value="https://gitea.musk.fun/api/packages/nocr/nuget/index.json" />' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' </packageSources>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <packageSourceMapping>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <packageSource key="musk.fun.nocr">' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <package pattern="Nocr.*" />' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' </packageSource>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <packageSource key="nuget.org">' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' <package pattern="*" />' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' </packageSource>' >> /root/.nuget/NuGet/NuGet.Config && \
echo ' </packageSourceMapping>' >> /root/.nuget/NuGet/NuGet.Config && \
echo '</configuration>' >> /root/.nuget/NuGet/NuGet.Config
# Add custom NuGet source (no API key needed for public read access)
RUN dotnet nuget add source https://gitea.musk.fun/api/packages/nocr/nuget/index.json --name musk
# Restore with verbose logging to see what's happening
# Restore with verbose logging
RUN dotnet restore "src/Nocr.TextMatcher.Migrator/Nocr.TextMatcher.Migrator.csproj" --verbosity normal
WORKDIR "/src/src/Nocr.TextMatcher.Migrator"
RUN dotnet build "Nocr.TextMatcher.Migrator.csproj" -c Release -o /app/build