I have a ASP.NET Core api for which I want to build a Docker image using VisualStudio 2017. I used Add Docker Support -> Linux and it generated the Dockerfile, and as I want to use a NuGet.Config file, I modified it consequently (COPY NuGet.Config .) and I use the NuGet.Config file during dotnet restore as you can see below:
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY NuGet.Config ./
COPY ["Stock.Api/Stock.Api.csproj", "Stock.Api/"]
COPY ["Business/Stock/Stock.csproj", "Business/Stock/"]
COPY ["Business/Stock.Dto/Stock.Dto.csproj", "Business/Stock.Dto/"]
RUN dotnet restore --configfile NuGet.Config "Stock.Api/Stock.Api.csproj"
COPY . .
WORKDIR "/src/Stock.Api"
RUN dotnet build "Stock.Api.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "Stock.Api.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Stock.Api.dll"]
And here is the NuGet.Config file I use which has two NuGet feeds, a public https://api.nuget.org/v3/index.json and a LOCAL private feed http://192.168.40.100:3000/nuget (192.168.40.100 is my local @IP)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="MYPRIVATEFEED" value="http://192.168.40.100:3000/nuget" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
Using VS2017, I try to build the Docker image, and it fails with a timeout at the step 10 during dotnet restore as you can see:
Step 10/19 : RUN dotnet restore --configfile NuGet.Config "Stock.Api/Stock.Api.csproj"
3> ---> Running in 5c8827a8d62d
3> Restoring packages for /src/Business/Stock/Stock.csproj...
3> Retrying 'FindPackagesByIdAsyncCore' for source 'http://192.168.40.100:3000/nuget/FindPackagesById()?id='Dto.Base'&semVerLevel=2.0.0'.
3> The HTTP request to 'GET http://192.168.40.100:3000/nuget/FindPackagesById()?id='Dto.Base'&semVerLevel=2.0.0' has timed out after 100000ms.
I don't know why there is a timeout because the local feed is within my local computer. I modified the DNS using Docker for Desktop to automatic to static, I tried a lot of things I found on internet, but without any success.
Does anybody have a clue ?
Thank you very much