I'm trying to create a pipeline in AzureDevops, so I have the following Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
COPY ["WebApi/WebApi.csproj", "WebApi/"]
RUN dotnet restore "WebApi/WebApi.csproj"
COPY . .
WORKDIR "/src/WebApi"
RUN dotnet build "WebApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "WebApi.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApi.dll"]
When I try to run my pipeline I got the following error:
Step 7/17 : COPY ["WebApi/WebApi.csproj", "WebApi/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder651276881/WebApi/WebApi.csproj: no such file or directory
##[error]COPY failed: stat /var/lib/docker/tmp/docker-builder651276881/WebApi/WebApi.csproj: no such file or directory
##[error]/usr/bin/docker failed with return code: 1
I noted that AzureDevops build my Docker outsite the folder, with this command:
/usr/bin/docker build -f /home/vsts/work/1/s/WebApi/Dockerfile -t repository:9 /home/vsts/work/1/s/WebApi
I think I need enter in WebApi/ folder to execute the Build, because my Dockerfile try to copy the files.