Quantcast
Channel: User learning... - Stack Overflow
Viewing all articles
Browse latest Browse all 38

Answer by learning... for How to dockerize multiple projects in ASP.NET Core?

$
0
0

I got my self into similar position. Above post by @Cristian Ruscanu helped understand the issue. However, i used the solution as detailed in this post

https://medium.com/@bukunmi.aluko/dockerize-asp-net-core-web-app-with-multiple-layers-projects-part1-2256aa1b0511

My structure

--Root

++.sln

++Project.Core

====Project.Core.csproj

++Project.WebApi

====Project.WebApi.csproj

  1. The DockerFile is inside the Project.WebApi project
  2. .dockerignore file is at the solution level

Ran the command at the solution level and not at Project.WebApi`

docker build -f Project.WebApi/Dockerfile -t Username/testApi .`

Here is the complete Dockerfile for me

#Multiproject solution#All projects are at the same level#Project1: Project.Core#Project2: Project.WebApi#Entry project is Project.WebApi#Docker file created in Project.WebApi#.dockerignore placed at solution level#image to start from and put a reference as base, sdk is only for the build  since it is quite largeFROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base#add the work dir that the container will start in#any future commands will happen in this dirWORKDIR /app#buildFROM mcr.microsoft.com/dotnet/sdk:8.0 AS buildARG BUILD_CONFIGURATION=ReleaseWORKDIR /src#copy the csproj and restore as distinct layersCOPY Project.Core/*.csproj ./Project.Core/COPY Project.WebApi/*.csproj ./Project.WebApi/RUN dotnet restore "./Project.WebApi/./Project.WebApi.csproj"COPY . .WORKDIR "/src/Project.WebApi"RUN dotnet build "./Project.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/buildFROM build AS publishARG BUILD_CONFIGURATION=ReleaseRUN dotnet publish "./Project.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/out /p:UseAppHost=falseFROM base AS finalWORKDIR /appCOPY --from=publish /app/out .ENTRYPOINT ["dotnet", "Project.WebApi.dll"]

Viewing all articles
Browse latest Browse all 38

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>