I have a dockerfile that is working on my local machine but is not working on my azure pipelines build.
I've referenced this link here: Docker: COPY failed: file not found in build context (Dockerfile) but was unable to get the docker context for my solution to work properly.
Project File Structure:
AzureProject.sln
|AzureProject
|Classes
||DockerFile
||AzureProject.csproj
.dockerignore
.gitignore
My Docker file is the default file built on creation when you select "include docker" with your .NET 6 project. Again located in: AzureProject/Dockerfile
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
WORKDIR /src
COPY ["AzureProject/AzureProject.csproj", "AzureProject/"]
RUN dotnet restore "AzureProject/AzureProject.csproj"
COPY . .
WORKDIR "/src/AzureProject"
RUN dotnet build "AzureProject.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "AzureProject.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AzureProject.dll"]
Lastly, my azure-pipelines.yml file looks like
steps:
- task: Docker@2
displayName: buildAndPush
inputs:
containerRegistry: AzureCR
repository: AzureCR-NET6
Dockerfile: AzureProject/Dockerfile
Edit 1: Folder Structure in VS2022