Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 935
Cristian Grisolia Avatar asked Jan 21 '26 22:01

Cristian Grisolia


2 Answers

This might happen when the file you want to COPY is also in the .dockerignore

like image 151
Jeroen Wijdemans Avatar answered Jan 24 '26 11:01

Jeroen Wijdemans


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

e.g. nginx.conf |-MyLocalShop

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

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

like image 37
Luke Briner Avatar answered Jan 24 '26 11:01

Luke Briner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!