blazor 服务器/客户端应用程序到 google appengine 的部署问题

问题描述 投票:0回答:1

我有一个 Blazor (.NET 6) 服务器/客户端应用程序,并尝试将其部署到 google appengine。当我使用 https 或作为容器 (Dockerfile) 启动该应用程序时,该应用程序在 Visual Studio 中本地运行良好。当我去部署它并运行时

gcloud app deploy

我收到此错误:

Step 8/18 : RUN dotnet restore "./SevenOfNine/Server/SevenOfNine.Server.csproj"
 ---> Running in b72b6927c101
MSBUILD : error MSB1009: Project file does not exist.
Switch: ./SevenOfNine/Server/SevenOfNine.Server.csproj
The command '/bin/sh -c dotnet restore "./SevenOfNine/Server/SevenOfNine.Server.csproj"' returned a non-zero code: 1

这是我的 Dockerfile:

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

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

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["SevenOfNine/Server/SevenOfNine.Server.csproj", "SevenOfNine/Server/"]
COPY ["SevenOfNine/Server/holodeckhub-da6f4d98c75e.json", "SevenOfNine/Server/"]
COPY ["SevenOfNine.Models/SevenOfNine.Models.csproj", "SevenOfNine.Models/"]
COPY ["SevenOfNine/Client/SevenOfNine.Client.csproj", "SevenOfNine/Client/"]
COPY ["SevenOfNine/Shared/SevenOfNine.Shared.csproj", "SevenOfNine/Shared/"]
RUN dotnet restore "./SevenOfNine/Server/SevenOfNine.Server.csproj"
COPY . .
WORKDIR "/src/SevenOfNine/Server"
RUN dotnet build "./SevenOfNine.Server.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./SevenOfNine.Server.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

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

这是我的 app.yaml,以防有帮助:

    runtime: custom
    env: flex

我正在从服务器文件夹运行 gcloud 应用程序部署。 文件夹结构为:

\BorgCollective\
   BorgCollective.sln
   .dockerignore
   SevenOfNine\
      Server\
         SevenOfNine.Server.csproj
         Dockerfile
      Client\
         SevenOfNine.Client.csproj

为了彻底起见,这是我的 .dockerignore 文件

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
docker google-app-engine dockerfile blazor blazor-server-side
1个回答
0
投票

我的大部分问题都在这篇帖子中得到了解答。我仍然在这里做一个单独的答案,以更详细地阐明这些步骤。假设您已准备好将应用程序部署到 Google App Engine,并且您已经安装了 Google Cloud CLI。

  1. 转到您的 blazor 服务器项目,并将 Dockerfile 替换为链接答案中的 Dockerfile。
  2. 在发布模式下发布您的应用程序。
  3. 打开命令提示符,导航到服务器应用程序的文件夹并输入
    gcloud app deploy
  4. 验证其表示将部署到的值。
  5. 按 Y 继续。
  6. 部署完成后,单击控制台日志输出末尾的链接以验证 Web 应用程序是否已成功部署。
© www.soinside.com 2019 - 2024. All rights reserved.