简体   繁体   中英

Dockerfile: Getting failed to compute cache key: "/nginx.conf" not found: not found

I'm working on a Blazor Wasm (ASP.Net Core hosted consisting on the usual 3 projects Client, Server and Shared) app that I want to deploy to Linux using docker. I'm copying a nginx.conf file to the Server project root folder but when trying to publish to Azure App Service Containers I'm getting:

failed to compute cache key: "/nginx.conf" not found: not found

This is my 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"]

If I run the dotnet publish command to check the ouput directory within app/publish, I can see the file is actually there. What am I missing?

当您要复制的文件也在.dockerignore时,可能会发生这种情况

也许您的项目中缺少nginx.conf文件。

Are you setting the context of the docker build to the directory that contains the nginx.conf and not a directory below that?

eg nginx.conf |-MyLocalShop

Bad: docker build -t something:latest -f ./DockerFile ./MyLocalShop

Good: docker build -t something:latest -f ./DockerFile .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM