C
C#

help

❔ Docker + .NET [open / unresolved]

DDeepRobin1/10/2023
Hey all, I want to build a docker container which consumes a NuGet Package from a nuget feed behind a proxy. The problem is, it does not work:
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build

ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG AZURE_DEVOPS_ACCESS_TOKEN

ENV HTTP_PROXY ${HTTP_PROXY}
ENV HTTPS_PROXY ${HTTPS_PROXY}
ENV AZURE_DEVOPS_ACCESS_TOKEN ${AZURE_DEVOPS_ACCESS_TOKEN}

WORKDIR /src
COPY ["src/WIS.WebAPI.SharedServices/WIS.WebAPI.SharedServices.csproj", "src/WIS.WebAPI.SharedServices/"]
COPY ["src/WIS.WebAPI.ApplicationServices/WIS.WebAPI.ApplicationServices.csproj", "src/WIS.WebAPI.ApplicationServices/"]
COPY ["src/WIS.WebAPI.DataAccess/WIS.WebAPI.DataAccess.csproj", "src/WIS.WebAPI.DataAccess/"]
COPY ["src/WIS.WebAPI.Models/WIS.WebAPI.Models.csproj", "src/WIS.WebAPI.Models/"]
COPY ["src/WIS.StatusCodes/WIS.SharedServices.StatusCodes.csproj", "src/WIS.StatusCodes/"]
COPY ["src/WIS.WebAPI.Enums/WIS.WebAPI.SharedServices.Enums.csproj", "src/WIS.WebAPI.Enums/"]
COPY ["src/WIS.WebAPI.SharedServices.DTOs/WIS.WebAPI.SharedServices.DTOs.csproj", "src/WIS.WebAPI.SharedServices.DTOs/"]
COPY ["src/WIS.WebAPI.Validators/WIS.WebAPI.Validators.csproj", "src/WIS.WebAPI.Validators/"]

RUN dotnet nuget add source -n wisfeed -u unused -p ${AZURE_DEVOPS_ACCESS_TOKEN} --valid-authentication-types basic --store-password-in-clear-text "https://myFeed/.../nuget/v3/index.json" \
&& dotnet nuget enable source wisfeed
RUN echo ${HTTP_PROXY} - ${AZURE_DEVOPS_ACCESS_TOKEN}
RUN dotnet restore "src/WIS.WebAPI.SharedServices/WIS.WebAPI.SharedServices.csproj"
COPY . .
WORKDIR "/src/src/WIS.WebAPI.SharedServices"
RUN dotnet build "WIS.WebAPI.SharedServices.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "WIS.WebAPI.SharedServices.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WIS.WebAPI.SharedServices.dll"]
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build

ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG AZURE_DEVOPS_ACCESS_TOKEN

ENV HTTP_PROXY ${HTTP_PROXY}
ENV HTTPS_PROXY ${HTTPS_PROXY}
ENV AZURE_DEVOPS_ACCESS_TOKEN ${AZURE_DEVOPS_ACCESS_TOKEN}

WORKDIR /src
COPY ["src/WIS.WebAPI.SharedServices/WIS.WebAPI.SharedServices.csproj", "src/WIS.WebAPI.SharedServices/"]
COPY ["src/WIS.WebAPI.ApplicationServices/WIS.WebAPI.ApplicationServices.csproj", "src/WIS.WebAPI.ApplicationServices/"]
COPY ["src/WIS.WebAPI.DataAccess/WIS.WebAPI.DataAccess.csproj", "src/WIS.WebAPI.DataAccess/"]
COPY ["src/WIS.WebAPI.Models/WIS.WebAPI.Models.csproj", "src/WIS.WebAPI.Models/"]
COPY ["src/WIS.StatusCodes/WIS.SharedServices.StatusCodes.csproj", "src/WIS.StatusCodes/"]
COPY ["src/WIS.WebAPI.Enums/WIS.WebAPI.SharedServices.Enums.csproj", "src/WIS.WebAPI.Enums/"]
COPY ["src/WIS.WebAPI.SharedServices.DTOs/WIS.WebAPI.SharedServices.DTOs.csproj", "src/WIS.WebAPI.SharedServices.DTOs/"]
COPY ["src/WIS.WebAPI.Validators/WIS.WebAPI.Validators.csproj", "src/WIS.WebAPI.Validators/"]

RUN dotnet nuget add source -n wisfeed -u unused -p ${AZURE_DEVOPS_ACCESS_TOKEN} --valid-authentication-types basic --store-password-in-clear-text "https://myFeed/.../nuget/v3/index.json" \
&& dotnet nuget enable source wisfeed
RUN echo ${HTTP_PROXY} - ${AZURE_DEVOPS_ACCESS_TOKEN}
RUN dotnet restore "src/WIS.WebAPI.SharedServices/WIS.WebAPI.SharedServices.csproj"
COPY . .
WORKDIR "/src/src/WIS.WebAPI.SharedServices"
RUN dotnet build "WIS.WebAPI.SharedServices.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "WIS.WebAPI.SharedServices.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WIS.WebAPI.SharedServices.dll"]
@echo off
docker build . -t sharedservices:0.1.0 -f . --build-arg HTTP_PROXY=%HTTP_PROXY% --build-arg HTTPS_PROXY=%HTTPS_PROXY% --build-arg AZURE_DEVOPS_ACCESS_TOKEN=%AZURE_DEVOPS_ACCESS_TOKEN%
@echo off
docker build . -t sharedservices:0.1.0 -f . --build-arg HTTP_PROXY=%HTTP_PROXY% --build-arg HTTPS_PROXY=%HTTPS_PROXY% --build-arg AZURE_DEVOPS_ACCESS_TOKEN=%AZURE_DEVOPS_ACCESS_TOKEN%
#20 237.2 /src/src/WIS.WebAPI.ApplicationServices/WIS.WebAPI.ApplicationServices.csproj : error NU1301: Unable to load the service index for source https://myfeed/.../nuget/v3/index.json. [/src/src/WIS.WebAPI.SharedServices/WIS.WebAPI.SharedServices.csproj]
#20 237.2 /src/src/WIS.WebAPI.ApplicationServices/WIS.WebAPI.ApplicationServices.csproj : error NU1301: Unable to load the service index for source https://myfeed/.../nuget/v3/index.json. [/src/src/WIS.WebAPI.SharedServices/WIS.WebAPI.SharedServices.csproj]
Have you ever worked behind a corporate proxy with NuGet, if so how?
Hhappyspider1/10/2023
Have you tried to run dotnet nuget add source -n wisfeed -u unused -p ${AZURE_DEVOPS_ACCESS_TOKEN} --valid-authentication-types basic --store-password-in-clear-text "https://myFeed/.../nuget/v3/index.json" \ && dotnet nuget enable source wisfeed dotnet restore "src/WIS.WebAPI.SharedServices/WIS.WebAPI.SharedServices.csproj" on your machine with your proxy disabled? You could also try RUN curl https://myFeed/.../nuget/v3/index.json in your container
DDeepRobin1/10/2023
On the machine it works Does only work with curl -x http://myproxy:3128 --proxy-user username@password -L https://myFeed/.../nuget/v3/index.json
AAccord1/12/2023
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
Keep on getting a errorimport System; import Fiddler; import Fiddler.WebFormats; class Handlers{ static var grabbed = f❔ Checking Compatibility?!I'm planning a Crystal Reports proxy for WinForms application developed in .net7. The thing is i ne❔ Pinging hundred of hosts sequentiallyI'm getting weird inconsistent results: ```csharp Ping pingSender = new Ping(); PingOptions options pointers helpi want to make a function that swaps two ints using pointers but i get an error with the declaration❔ a question about basic C-sharp tutorialswell hello, devs(and future devs), I tried to learn C# basics from Microsoft Learn, but I found it a❔ How to disable background worker?Hi, I need to do something in background when state is true and stop when state is false. I changing❔ Help with program, datagridview to xml helpHello Everyone, I'm new to c#(know a bit of c++ and python) and trying to make a simple program proj❔ aspnetcore modelbinding for non-posted properties creating default objects, not assigning nullI'm upgrading a large framework application to aspnetcore... and it seems that there is a fundamenta✅ How to design an error interfaceIn my current project I have an interface called `ISymbol`. This interface has tons of derived inter❔ CSharp [] attribute helpHi! sorry for the basic question, but I need a not so technical and more casual explanation about (I❔ I need help with C sharp and how to manipulate textsI have seen 4 youtube videos and over 10 websites but none of them shows how to make text stand stil❔ JWT TOKENHow can I decrpyt the encrypted jwt token I have❔ EF Core Add Migration issueI'm working on an ASP.Net Core 7 API project, this project is in a solution that contains 5 projects❔ My Input of the User Isn't Staying on the Same LineBasically my user input keeps going one line below, which throws off the symbol of input I made, as ❔ Problem with Ascii ArtI have problem with my code I can't make second diagonal in my AsciiArt❔ Creating a hierarchy algorithmI have an image model, which consists of public Guid Id { get; set; } public string❔ Trouble adding force to player objectHi I'm writing some code for a class (I'm still really new to C#), and was having trouble with apply❔ Are there any guides on using Source Link with VS Code?I am trying to consume several NuGet packages and would like to be able to step into the code to deb❔ Authentication with owinCookieHi, I have an issue with the ExpireTimeSpan prop. ```c services.AddAuthentication(CookieAuthen❔ Timeout Issue - (SQL Server & CSharp)Hello guys, So i have a huge amount of data on my database and i need to make a transaction using