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
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"]