I'm trying to setup a real basic .net 5.0 API in Docker. I'm completely new to Docker so for the most part, I think I have what is needed, but I ran into a snag. I am using an internal NuGet package. I create a NuGet.Config file with the PackageSource listed in there. Now when I run the docker-compose script, it appears to find the NuGet repo, but now it's saying Authentication denied. I don't know the companies settings for credentials, but I'm trying to figure out how to do the following:
- Create some sort of ApiKey for the NuGet package
- Add the reference in NuGet.Config so I don't have to use personal credentials in the Dockerfile.
If there are any better examples/solutions, please let me know.
This is what I have so far.NOTE, I am on a Windows 10 machine.
NuGet.Config:
<configuration><packageSources><clear /><add key="<KeyName>" value="<URL PATH>/nuget/v3/index.json" /><add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /></packageSources><packageRestore><add key="enabled" value="True" /><add key="automatic" value="True" /></packageRestore></configuration>
Here is the docker-compse.yml
version: "3"services: democore.api: build: . ports: - "8163:8163"
Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:5.0.102-ca-patch-buster-slim-amd64 AS buildWORKDIR /srcCOPY ["DemoCore.Api.sln", "./"]COPY ["DemoCore.Api.csproj", "./"]COPY NuGet.Config ./RUN dotnet restore "DemoCore.Api.csproj"COPY . .RUN dotnet build "DemoCore.Api.csproj" -c Release -o /appFROM build AS publishRUN dotnet publish "DemoCore.Api.csproj" -c Release -o /appFROM mcr.microsoft.com/dotnet/sdk:5.0.102-ca-patch-buster-slim-amd64 AS baseWORKDIR /appEXPOSE 8163FROM base AS finalWORKDIR /appCOPY --from=publish /app .ENTRYPOINT ["dotnet", "DemoCore.Api.dll"]
When I run this in command prompt, this is the result:
Any help would be great.