github.com/anchore/syft@v1.38.2/syft/pkg/cataloger/dotnet/test-fixtures/image-net8-app-with-runtime-nodepsjson/Dockerfile (about) 1 # This represents a basic .NET project build where the project dependencies are downloaded and the project is built. 2 # The output is a directory tree of DLLs, a project.lock.json (not used in these tests), a .deps.json file, and 3 # a .runtimeconfig.json file (not used in these tests). 4 # With this deployment strategy there IS a bundled runtime. 5 FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:8.0-alpine@sha256:7d3a75ca5c8ac4679908ef7a2591b9bc257c62bd530167de32bba105148bb7be AS build 6 ARG RUNTIME=win-x64 7 WORKDIR /src 8 9 # copy csproj and restore as distinct layers 10 COPY src/*.csproj . 11 COPY src/packages.lock.json . 12 RUN dotnet restore -r $RUNTIME --verbosity normal --locked-mode 13 14 # copy and publish app and libraries 15 COPY src/ . 16 RUN dotnet publish -r $RUNTIME --no-restore -o /app 17 18 # remove the deps.json ... important! 19 RUN rm -f /app/dotnetapp.deps.json 20 21 FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/runtime:8.0@sha256:a6fc92280fbf2149cd6846d39c5bf7b9b535184e470aa68ef2847b9a02f6b99e 22 WORKDIR /app 23 COPY --from=build /app . 24 # just a nice to have for later... 25 #COPY --from=build /src/packages.lock.json . 26 27 # this is an odd choice, but possible 28 RUN rm -f /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.14/Microsoft.NETCore.App.deps.json 29 30 # this is a more realistic application image since the runtime is with the app 31 ENTRYPOINT ["dotnet", "dotnetapp.dll"] 32