tmds / linux-dev-certs

55 stars 8 forks source link

Unhandled exception: System.IO.IOException: Broken pipe #35

Closed kimek closed 1 week ago

kimek commented 2 months ago
Step 29/33 : RUN  /usr/local/share/dotnet-tools/dotnet-linux-dev-certs install
 ---> Running in dc5d31523c8c
Some operations require root. You may be prompted for your 'sudo' password.
Creating CA certificate.
Installing CA certificate.
Unhandled exception: System.IO.IOException: Broken pipe
 ---> System.Net.Sockets.SocketException (32): Broken pipe
   at System.Net.Sockets.Socket.Send(ReadOnlySpan`1 buffer, SocketFlags socketFlags)
   at System.IO.Pipes.PipeStream.WriteCore(ReadOnlySpan`1 buffer)
   --- End of inner exception stack trace ---
   at System.IO.Pipes.PipeStream.WriteCore(ReadOnlySpan`1 buffer)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Write(Char[] buffer)
   at LinuxDevCerts.ProcessHelper.Execute(String[] arguments, Char[] input, Boolean sudo) in /home/tmds/repos/linux-dev-certs/src/linux-dev-certs/ProcessHelper.cs:line 48
   at LinuxDevCerts.ProcessHelper.SudoExecute(String[] arguments, Char[] input) in /home/tmds/repos/linux-dev-certs/src/linux-dev-certs/ProcessHelper.cs:line 10
   at LinuxDevCerts.SystemCertificateStore.TryInstallCertificate(String name, X509Certificate2 certificate) in /home/tmds/repos/linux-dev-certs/src/linux-dev-certs/SystemCertificateStore.cs:line 44
   at LinuxDevCerts.CertificateManager.InstallAndTrust(Boolean installDeps) in /home/tmds/repos/linux-dev-certs/src/linux-dev-certs/CertificateManager.cs:line 53
   at Program.<>c__DisplayClass0_0.<<Main>$>b__0(InvocationContext ctx) in /home/tmds/repos/linux-dev-certs/src/linux-dev-certs/Program.cs:line 24
   at System.CommandLine.Invocation.AnonymousCommandHandler.Invoke(InvocationContext context)
   at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()

when running as root:

Step 25/29 : RUN  /usr/local/share/dotnet-tools/dotnet-linux-dev-certs install
 ---> Running in b09859420cda
The tool is running with elevated privileges. You should run under the user account of the developer.

dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
EXPOSE 5000
EXPOSE 5001

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app

COPY ./Sitefinity.Renderer/. .
RUN dotnet nuget add source "https://nuget.sitefinity.com/nuget/"
RUN dotnet add package "some packages here without any errors"

RUN dotnet restore "Renderer.sln"
RUN dotnet build "Renderer.csproj" -c Release -o /app/build
RUN dotnet restore
RUN dotnet publish "Renderer.csproj" -c Release -o /app/out

RUN dotnet tool update linux-dev-certs --tool-path /usr/local/share/dotnet-tools

# Change to none-root user
ENV APP_USER app_user
RUN useradd -r $APP_USER
RUN chown app_user:app_user  '/usr/local/share/dotnet-tools'
USER $APP_USER

RUN  /usr/local/share/dotnet-tools/dotnet-linux-dev-certs install
tmds commented 2 months ago

"Some operations require root. You may be prompted for your 'sudo' password."

The tool wants to do something as root and that therefore requires sudo to work for the non-root user.

You need to add some additional things to the Dockerfile to enable the APP_USER to use sudo.

If you have added the configuration that makes this work:

RUN sudo echo hello

then the tool should work as well.

tmds commented 2 months ago

@kimek were you able to make this work?

tmds commented 1 week ago

Closing due to inactivity.