3

我正在尝试使用 AspNetCore3 preview6.19307.2 开发一个 Web 应用程序,我会在我的 Azure WebApp 上发布。

我不是第一次尝试发布 AspNetCore 3 的预览版。不知什么原因,我不能。WebApp 应用程序告诉我它无法启动(内部服务器错误)。

在 Kudu 控制台中,当我尝试 AspNetCore3 Preview5 时,我已经安装了ASP.NET Core 3.0 (x64) Runtime(版本 3.0.0-preview5-19227-01)。

现在,自 Preview6 以来,此版本不存在扩展。

因此,我尝试在 Docker 上使用该应用程序。

我尝试了几个 dockerfile,包括:

由 Visual Studio 生成:

FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim-arm64v8 AS base
WORKDIR /app
EXPOSE 80

# Install ASP.NET Core
ENV ASPNETCORE_VERSION 3.0.0-preview6.19307.2

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj", "IdeaStudio.Web.Server/"]
COPY ["IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj", "IdeaStudio.Web.Client/"]
COPY ["IdeaStudio.Web.Shared/IdeaStudio.Web.Shared.csproj", "IdeaStudio.Web.Shared/"]
RUN dotnet restore "IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj"
COPY . .
WORKDIR "/src/IdeaStudio.Web.Server"
RUN dotnet build "IdeaStudio.Web.Server.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "IdeaStudio.Web.Server.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "IdeaStudio.Web.Server.dll"]

第一个记录:

1>------ Build started: Project: IdeaStudio.Web.Server, Configuration: Debug Any CPU ------
...
1>docker run -dt -v "C:\Users\andre\vsdbg\vs2017u5:/remote_debugger:rw" -v "D:\Repos\IdeaStudio.Web\IdeaStudio.Web.Server:/app" -v "C:\Users\andre\.nuget\packages\:/root/.nuget/fallbackpackages3" -v "C:\Microsoft\Xamarin\NuGet\:/root/.nuget/fallbackpackages" -v "C:\Program Files\dotnet\sdk\NuGetFallbackFolder:/root/.nuget/fallbackpackages2" -e "DOTNET_USE_POLLING_FILE_WATCHER=1" -e "ASPNETCORE_ENVIRONMENT=Development" -e "NUGET_PACKAGES=/root/.nuget/fallbackpackages3" -e "NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages;/root/.nuget/fallbackpackages2;/root/.nuget/fallbackpackages3" -p 50793:80 --entrypoint tail ideastudiowebserver:dev -f /dev/null
1>259a71fe9c5e97288455ce841990821bcc4745ac11016b140e36950a6a49e1a3
1>docker: Error response from daemon: driver failed programming external connectivity on endpoint amazing_cocks (56655f71f121511a010d160258f20026756cf13a08014626064fdebc94709c1d): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:50793:tcp:172.17.0.2:80: input/output error.
1>C:\Users\andre\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.7.11\build\Container.targets(196,5): error CTP1002: An error occurred while attempting to run Docker container.

更新 1

在我最后一次尝试中,我尝试了 VSCode 和终端: docker build -t ideastudio -f Dockerfile .

我还有另一个错误:

error MSB6003: The specified task executable "node" could not be run. System.ComponentModel.Win32Exception (2): No such file or directory [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]

最初,我DOCKERFILE被添加到/src/Ideatudio.Web.Server文件夹中。在此消息之前,我的文件树看起来像

- IdeaStudio.Web.Client\ (csproj and files)
- IdeaStudio.Web.Server\ (csproj and files)
    - DOCKERFILE
- IdeaStudio.Web.Shared\...

后:

- IdeaStudio.Web.Client\ (csproj and files)
- IdeaStudio.Web.Server\ (csproj and files)
- IdeaStudio.Web.Shared\...
- DOCKERFILE

我有同样的错误...

更新 2

我已经在以下位置恢复了 docker 文件的原始版本(由 Visual Studio 生成) D:\repos\IdeaStudio.Web\src\IdeaStudio.Web.Server\DOCKERFILE

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj", "IdeaStudio.Web.Server/"]
COPY ["IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj", "IdeaStudio.Web.Client/"]
COPY ["IdeaStudio.Web.Shared/IdeaStudio.Web.Shared.csproj", "IdeaStudio.Web.Shared/"]
RUN dotnet restore "IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj"
COPY . .
WORKDIR "/src/IdeaStudio.Web.Server"
RUN dotnet build "IdeaStudio.Web.Server.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "IdeaStudio.Web.Server.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "IdeaStudio.Web.Server.dll"]

我的日志:

D:\Repos\IdeaStudio.Web\src\IdeaStudio.Web.Server>docker build -t ideastudioserver -f Dockerfile .
Sending build context to Docker daemon  3.224MB
Step 1/18 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
 ---> 535a4f32905a
Step 2/18 : WORKDIR /app
 ---> Running in c949c41906a2
Removing intermediate container c949c41906a2
 ---> 7e4f125c7680
Step 3/18 : EXPOSE 80
 ---> Running in 78304b88cdeb
Removing intermediate container 78304b88cdeb
 ---> b3498af84ab1
Step 4/18 : FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
 ---> 1fe3bc74dd1b
Step 5/18 : WORKDIR /src
 ---> Using cache
 ---> ac9cfd234501
Step 6/18 : COPY ["IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj", "IdeaStudio.Web.Server/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder106022311/IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj: no such file or directory

当我将其移至D:\repos\IdeaStudio.Web\src\DOCKERFILE

D:\Repos\IdeaStudio.Web\src>docker build -t ideastudioserver -f Dockerfile .
Sending build context to Docker daemon  48.93MB
Step 1/18 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
 ---> 535a4f32905a
Step 2/18 : WORKDIR /app
 ---> Using cache
 ---> 7e4f125c7680
Step 3/18 : EXPOSE 80
 ---> Using cache
 ---> b3498af84ab1
Step 4/18 : FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
 ---> 1fe3bc74dd1b
Step 5/18 : WORKDIR /src
 ---> Using cache
 ---> ac9cfd234501
Step 6/18 : COPY ["IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj", "IdeaStudio.Web.Server/"]
 ---> c258e7588817
Step 7/18 : COPY ["IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj", "IdeaStudio.Web.Client/"]
 ---> 73d1ce9fcd0a
Step 8/18 : COPY ["IdeaStudio.Web.Shared/IdeaStudio.Web.Shared.csproj", "IdeaStudio.Web.Shared/"]
 ---> fb4cdea5ed62
Step 9/18 : RUN dotnet restore "IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj"
 ---> Running in f7452d7650cf
  Restore completed in 5.7 sec for /src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj.
  Restore completed in 4.23 ms for /src/IdeaStudio.Web.Shared/IdeaStudio.Web.Shared.csproj.
  Restore completed in 6.17 sec for /src/IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj.
Removing intermediate container f7452d7650cf
 ---> 5720a6dea18d
Step 10/18 : COPY . .
 ---> 86ef33c9acaf
Step 11/18 : WORKDIR "/src/IdeaStudio.Web.Server"
 ---> Running in a2581bbcbece
Removing intermediate container a2581bbcbece
 ---> be52c244051d
Step 12/18 : RUN dotnet build "IdeaStudio.Web.Server.csproj" -c Release -o /app
 ---> Running in e43ee85a4a35
Microsoft (R) Build Engine version 16.2.0-preview-19278-01+d635043bd for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 25.27 ms for /src/IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj.
  Restore completed in 24.18 ms for /src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj.
  Restore completed in 0.65 ms for /src/IdeaStudio.Web.Shared/IdeaStudio.Web.Shared.csproj.
/usr/share/dotnet/sdk/3.0.100-preview6-012264/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(158,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/src/IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj]
/usr/share/dotnet/sdk/3.0.100-preview6-012264/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(158,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/src/IdeaStudio.Web.Shared/IdeaStudio.Web.Shared.csproj]
  IdeaStudio.Web.Shared -> /app/IdeaStudio.Web.Shared.dll
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003: The specified task executable "node" could not be run. System.ComponentModel.Win32Exception (2): No such file or directory [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean 
setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at System.Diagnostics.Process.Start() [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]    
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at TypeScript.Tasks.VsTsc.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.Execute() [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]

Build FAILED.

/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003: The specified task executable "node" could not be run. System.ComponentModel.Win32Exception (2): No such file or directory [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean 
setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at System.Diagnostics.Process.Start() [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]    
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at TypeScript.Tasks.VsTsc.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
/root/.nuget/packages/microsoft.typescript.msbuild/3.5.2/tools/Microsoft.TypeScript.targets(543,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.Execute() [/src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:03.96
The command '/bin/sh -c dotnet build "IdeaStudio.Web.Server.csproj" -c Release -o /app' returned a non-zero code: 1
4

1 回答 1

0

您的问题与相对路径有关。对于COPY,第一个值是相对于当前 dockerfile 路径,第二个参数是相对于 dockerWORKDIR容器中的。

试试下面的 dockerfile:

    FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
    WORKDIR /app
    EXPOSE 80

    FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
    WORKDIR /src
    COPY ["src/IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj", "IdeaStudio.Web.Server/"]
    COPY ["src/IdeaStudio.Web.Client/IdeaStudio.Web.Client.csproj", "IdeaStudio.Web.Client/"]
    COPY ["src/IdeaStudio.Web.Shared/IdeaStudio.Web.Shared.csproj", "IdeaStudio.Web.Shared/"]
    RUN dotnet restore "IdeaStudio.Web.Server/IdeaStudio.Web.Server.csproj"
    COPY "src" .
    WORKDIR "/src/IdeaStudio.Web.Server"
    RUN dotnet build "IdeaStudio.Web.Server.csproj" -c Release -o /app

    FROM build AS publish
    RUN dotnet publish "IdeaStudio.Web.Server.csproj" -c Release -o /app

    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app .
    ENTRYPOINT ["dotnet", "IdeaStudio.Web.Server.dll"]
于 2019-07-04T08:22:49.187 回答