arcus-azure / arcus.templates

Collection of .NET templates & tooling to get started very easily.
https://templates.arcus-azure.net
MIT License
18 stars 12 forks source link

base-images for runtime in Dockerfiles need to be reviewed #854

Closed fgheysels closed 3 months ago

fgheysels commented 9 months ago

When I create a new project based on the Arcus Messaging template, I can see that the generated dockerfile looks like this:

FROM mcr.microsoft.com/dotnet/sdk:6.0.301-alpine3.14 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0.301-alpine3.14 AS build
WORKDIR /src
COPY ["Arcus.Templates.ServiceBus.Topic.csproj", ""]

COPY . .
WORKDIR "/src/."
RUN dotnet build "Arcus.Templates.ServiceBus.Topic.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "Arcus.Templates.ServiceBus.Topic.csproj" -c Release -o /app

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

So, this means that the base-image that is used for running the project, is an SDK image. This is not necessary. We must use a 'runtime' image, like f.i. 6.0.25-alpine3.18-amd64

We must review all Dockerfiles in all templates to make sure that no 'sdk' versions are used for running our projects.

fgheysels commented 9 months ago

Shall we do this together with the .NET 8 release ?

stijnmoreels commented 9 months ago

Shall we do this together with the .NET 8 release ?

We could yes.