Containerize an ASP.NET Core Web API with Docker

Containerize a Web API for easy mocking and testing by Front-End developers

photo of a stack of  cargo container
photo of a stack of  cargo container
Photo by Tri Eptaroka Mardiana on Unsplash
Image for post
Image for post
Image for post
Image for post
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS baseWORKDIR /appEXPOSE 80FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS buildWORKDIR /srcCOPY ["IntroToMvc.csproj", "./"]RUN dotnet restore "./IntroToMvc.csproj"COPY . .# WORKDIR "/src/."RUN dotnet build "IntroToMvc.csproj" -c Release -o /app/buildFROM build AS publishRUN dotnet publish "IntroToMvc.csproj" -c Release -o /app/publishFROM base AS finalWORKDIR /appCOPY --from=publish /app/publish .ENTRYPOINT ["dotnet", "IntroToMvc.dll"]
Image for post
Image for post

I develop software by profession. My interests include: history, economics, politics & enterprise-architecture. I am a child of God.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store