Azure Pipeline to build docker images fails using same docker file in Visual Studio

后端 未结 5 1390
执笔经年
执笔经年 2021-02-19 09:43

I\'m trying to create a deployment pipeline to deploy my image to Kubernetes cluster. The first step in this process is to create an image based on the docker file. The docker

5条回答
  •  南旧
    南旧 (楼主)
    2021-02-19 10:12

    In my case, I had the following folder structure:

    +-- [REPOSITORY FOLDER]
    |   +-- [SOLUTION FOLDER]
    |   |   +-- [*.SLN]
    |   |   +-- [PROJECT Folder]
    |   |   |   +-- [*.CSPROJ]
    |   |   |   +-- [dockerfile]
    

    My docker file is inside the project folder.
    After modifying to use only the CSPROJ file in the first copy, and receiving the missing MAIN method error, not having a suitable static main entry point, I fixed it replacing the "copy .." to "COPY . [project_name]/"

    
    FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
    WORKDIR /app
    EXPOSE 80
    EXPOSE 443
    
    FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
    WORKDIR /src
    COPY ["SampleApi1.csproj", "SampleApi1/"]
    RUN dotnet restore "SampleApi1/SampleApi1.csproj"
    COPY . SampleApi1/
    WORKDIR "/src/SampleApi1"
    RUN dotnet build "SampleApi1.csproj" -c Release -o /app/build
    
    FROM build AS publish
    RUN dotnet publish "SampleApi1.csproj" -c Release -o /app/publish
    
    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app/publish .
    ENTRYPOINT ["dotnet", "SampleApi1.dll"]
    

提交回复
热议问题