Menu

Running a .NET 8+ App on Something Other Than Windows Part 2
📰

Running a .NET 8+ App on Something Other Than Windows Part 2

DEV Community: docker·Tomas Gallucci·1 day ago
#3vYiYxWS
#devtodocker#devto#dev#container#enter
Reading 0:00
15s threshold

In Part 1 we saw how to run a simple .NET app on macOS against .NET 10 1 .

Now, let's put this in a container.

First. I'm going to supply the entire Dockerfile. Then we'll walk through it.

FROM mcr.microsoft.com/dotnet/runtime:10.0 AS base USER $APP_UID WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build ARG BUILD_CONFIGURATION = Release WORKDIR /src COPY [ "HelloWorld.csproj" , "./" ] RUN dotnet restore "HelloWorld.csproj" COPY . . WORKDIR "/src/" RUN dotnet build "./HelloWorld.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish ARG BUILD_CONFIGURATION = Release RUN dotnet publish "./HelloWorld.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT [ "dotnet" , "HelloWorld.dll" ]

Enter fullscreen mode

Exit fullscreen mode

Overview

Let's start with a brief overview.

We use a total of four containers.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.