Skip to content
AgileLogics
4 min read

Packaging & Deployment

Prerequisites: Security fundamentals

dotnet publish -c Release -o ./publish
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
COPY . /src
WORKDIR /src
RUN dotnet publish -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:8.0
COPY --from=build /app .
ENTRYPOINT ["dotnet", "MyApp.dll"]

The two-stage build keeps the final image to just the runtime (not the full SDK), the same pattern used for Java's Spring Boot deployment. A CI/CD pipeline typically runs dotnet test on every push, then builds and pushes this image on a merge to the main branch.