Dockerfile:计算缓存键失败:“/nginx.conf”未找到:未找到
Dockerfile: Getting failed to compute cache key: "/nginx.conf" not found: not found
我正在开发一个 Blazor Wasm(ASP.Net 核心托管,由通常的 3 个项目客户端、服务器和共享组成)应用程序,我想使用 [=22= 将其部署到 Linux ].
我正在将 nginx.conf 文件复制到服务器项目根文件夹,但在尝试发布到 Azure 应用服务容器时,我得到:
failed to compute cache key: "/nginx.conf" not found: not found
这是我的 Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["MyLocalShop/Server/MyLocalShop.Server.csproj", "MyLocalShop/Server/"]
COPY ["MyLocalShop.Services.MongoDb/MyLocalShop.Services.MongoDb.csproj", "MyLocalShop.Services.MongoDb/"]
COPY ["MyLocalShop.Server.Contracts/MyLocalShop.Server.Contracts.csproj", "MyLocalShop.Server.Contracts/"]
COPY ["MyLocalShop/Shared/MyLocalShop.Shared.csproj", "MyLocalShop/Shared/"]
COPY ["MyLocalShop/Client/MyLocalShop.Client.csproj", "MyLocalShop/Client/"]
RUN dotnet restore "MyLocalShop/Server/MyLocalShop.Server.csproj"
COPY . .
WORKDIR "/src/MyLocalShop/Server"
RUN dotnet build "MyLocalShop.Server.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyLocalShop.Server.csproj" -c Release -o /app/publish
FROM nginx:alpine AS final
WORKDIR /app
COPY --from=publish /app/publish .
COPY nginx.conf /etc/nginx/nginx.conf
ENTRYPOINT ["dotnet", "MyLocalShop.Server.dll"]
如果我 运行 dotnet publish 命令检查 app/publish 中的输出目录,我可以看到该文件确实存在。
我错过了什么?
当您要复制的文件也在 .dockerignore
中时,可能会发生这种情况
可能你的项目中缺少nginx.conf文件。
您是否将 docker 构建的上下文设置为包含 nginx.conf 的目录而不是其下方的目录?
例如
nginx.conf
|-MyLocalShop
不好:docker build -t something:latest -f ./DockerFile ./MyLocalShop
好:docker build -t something:latest -f ./DockerFile .
我正在开发一个 Blazor Wasm(ASP.Net 核心托管,由通常的 3 个项目客户端、服务器和共享组成)应用程序,我想使用 [=22= 将其部署到 Linux ]. 我正在将 nginx.conf 文件复制到服务器项目根文件夹,但在尝试发布到 Azure 应用服务容器时,我得到:
failed to compute cache key: "/nginx.conf" not found: not found
这是我的 Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["MyLocalShop/Server/MyLocalShop.Server.csproj", "MyLocalShop/Server/"]
COPY ["MyLocalShop.Services.MongoDb/MyLocalShop.Services.MongoDb.csproj", "MyLocalShop.Services.MongoDb/"]
COPY ["MyLocalShop.Server.Contracts/MyLocalShop.Server.Contracts.csproj", "MyLocalShop.Server.Contracts/"]
COPY ["MyLocalShop/Shared/MyLocalShop.Shared.csproj", "MyLocalShop/Shared/"]
COPY ["MyLocalShop/Client/MyLocalShop.Client.csproj", "MyLocalShop/Client/"]
RUN dotnet restore "MyLocalShop/Server/MyLocalShop.Server.csproj"
COPY . .
WORKDIR "/src/MyLocalShop/Server"
RUN dotnet build "MyLocalShop.Server.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyLocalShop.Server.csproj" -c Release -o /app/publish
FROM nginx:alpine AS final
WORKDIR /app
COPY --from=publish /app/publish .
COPY nginx.conf /etc/nginx/nginx.conf
ENTRYPOINT ["dotnet", "MyLocalShop.Server.dll"]
如果我 运行 dotnet publish 命令检查 app/publish 中的输出目录,我可以看到该文件确实存在。 我错过了什么?
当您要复制的文件也在 .dockerignore
可能你的项目中缺少nginx.conf文件。
您是否将 docker 构建的上下文设置为包含 nginx.conf 的目录而不是其下方的目录?
例如 nginx.conf |-MyLocalShop
不好:docker build -t something:latest -f ./DockerFile ./MyLocalShop
好:docker build -t something:latest -f ./DockerFile .