|
1 | | -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build |
| 1 | +# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. |
2 | 2 |
|
3 | | -WORKDIR /src |
4 | | -COPY . . |
| 3 | +# This stage is used when running from VS in fast mode (Default for Debug configuration) |
| 4 | +FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base |
| 5 | +USER $APP_UID |
| 6 | +WORKDIR /app |
| 7 | +EXPOSE 8080 |
5 | 8 |
|
6 | | -RUN find . -type f -name 'appsettings.*.json' ! -name 'appsettings.json' -exec rm -f {} + |
7 | | -RUN find . -name 'launchSettings.json' -exec rm -f {} + |
8 | 9 |
|
9 | | -RUN dotnet publish "src/OpenApi.Client.Mcp/OpenApi.Client.Mcp.csproj" -c Release -o /app/ --nologo |
| 10 | +# This stage is used to build the service project |
| 11 | +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build |
| 12 | +ARG BUILD_CONFIGURATION=Release |
| 13 | +WORKDIR /src |
| 14 | +COPY ["Directory.Packages.props", "."] |
| 15 | +COPY ["Directory.Build.props", "."] |
| 16 | +COPY ["Directory.Build.targets", "."] |
| 17 | +COPY ["nuget.config", "."] |
| 18 | +COPY ["src/OpenApi.Client.Mcp/OpenApi.Client.Mcp.csproj", "src/OpenApi.Client.Mcp/"] |
| 19 | +COPY ["src/OpenApi.Client.SourceGenerators/OpenApi.Client.SourceGenerators.csproj", "src/OpenApi.Client.SourceGenerators/"] |
| 20 | +RUN dotnet restore "./src/OpenApi.Client.Mcp/OpenApi.Client.Mcp.csproj" |
| 21 | +COPY . . |
| 22 | +WORKDIR "/src/src/OpenApi.Client.Mcp" |
| 23 | +RUN dotnet build "./OpenApi.Client.Mcp.csproj" -c $BUILD_CONFIGURATION -o /app/build |
10 | 24 |
|
11 | | -FROM mcr.microsoft.com/dotnet/runtime:9.0 AS final |
| 25 | +# This stage is used to publish the service project to be copied to the final stage |
| 26 | +FROM build AS publish |
| 27 | +ARG BUILD_CONFIGURATION=Release |
| 28 | +RUN dotnet publish "./OpenApi.Client.Mcp.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false |
12 | 29 |
|
| 30 | +# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration) |
| 31 | +FROM base AS final |
13 | 32 | WORKDIR /app |
14 | | -COPY --from=build /app/ . |
15 | | - |
16 | | -ENTRYPOINT ["dotnet", "./OpenApi.Client.Mcp.dll"] |
| 33 | +COPY --from=publish /app/publish . |
| 34 | +ENTRYPOINT ["dotnet", "OpenApi.Client.Mcp.dll"] |
0 commit comments