Docker file for .Net Core 5

By James Kenny
1 min read

Table of Contents

This is my docker file for .net core 5

FROM AS build



# copy csproj and restore as distinct layers
COPY *.sln .
COPY X.Model/*.*.csproj ./X.Model/
COPY X.Data/*.*.csproj ./X.Data/
COPY X.Web/*.*.csproj ./X.Web/

# copy everything else and build app
COPY X.Model/. ./X.Model/
COPY X.Data/. ./X.Data/
COPY X.Web/. ./X.Web/

RUN dotnet restore

WORKDIR /app/ContentrApp.Web
RUN dotnet publish -c Release -o out

FROM AS runtime
COPY --from=build /app/ContentrApp.Web/out ./
ENTRYPOINT ["dotnet", "ContentrApp.Web.dll"]

I was playing around a bit more with ports in .net core 5 and changing them around more.

The other thing I've found is that the default dot images no longer build typescript during the build.

To build the typescript I've started adding nodejs into my images with this.

RUN curl -sL | bash - \ 
&& apt update \
&& apt install -y nodejs

Last Update: May 29, 2024

About the Author