github.com/grafana/pyroscope@v1.18.0/examples/tracing/dotnet/Dockerfile (about) 1 ARG SDK_VERSION=8.0 2 # The build images takes an SDK image of the buildplatform, so the platform the build is running on. 3 FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:$SDK_VERSION AS build 4 5 ARG TARGETPLATFORM 6 ARG BUILDPLATFORM 7 ARG SDK_VERSION 8 9 WORKDIR /dotnet 10 11 ADD example . 12 13 # Set the target framework to SDK_VERSION 14 RUN sed -i -E 's|<TargetFramework>.*</TargetFramework>|<TargetFramework>net'$SDK_VERSION'</TargetFramework>|' Example.csproj 15 16 # We hardcode linux-x64 here, as the profiler doesn't support any other platform 17 RUN dotnet publish -o . --framework net$SDK_VERSION --runtime linux-x64 --no-self-contained 18 19 # This fetches the SDK 20 FROM --platform=linux/amd64 pyroscope/pyroscope-dotnet:0.13.0-glibc AS sdk 21 22 # Runtime only image of the targetplatfrom, so the platform the image will be running on. 23 FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/aspnet:$SDK_VERSION 24 25 WORKDIR /dotnet 26 27 COPY --from=sdk /Pyroscope.Profiler.Native.so ./Pyroscope.Profiler.Native.so 28 COPY --from=sdk /Pyroscope.Linux.ApiWrapper.x64.so ./Pyroscope.Linux.ApiWrapper.x64.so 29 COPY --from=build /dotnet/ ./ 30 31 32 ENV CORECLR_ENABLE_PROFILING=1 33 ENV CORECLR_PROFILER={BD1A650D-AC5D-4896-B64F-D6FA25D6B26A} 34 ENV CORECLR_PROFILER_PATH=/dotnet/Pyroscope.Profiler.Native.so 35 ENV LD_PRELOAD=/dotnet/Pyroscope.Linux.ApiWrapper.x64.so 36 ENV LD_LIBRARY_PATH=/dotnet 37 38 ENV PYROSCOPE_APPLICATION_NAME=rideshare.dotnet.push.app 39 ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040 40 ENV PYROSCOPE_LOG_LEVEL=debug 41 ENV PYROSCOPE_PROFILING_ENABLED=1 42 ENV PYROSCOPE_PROFILING_ALLOCATION_ENABLED=true 43 ENV PYROSCOPE_PROFILING_CONTENTION_ENABLED=true 44 ENV PYROSCOPE_PROFILING_EXCEPTION_ENABLED=true 45 ENV PYROSCOPE_PROFILING_HEAP_ENABLED=true 46 ENV RIDESHARE_LISTEN_PORT=5000 47 48 49 CMD sh -c "ASPNETCORE_URLS=http://*:${RIDESHARE_LISTEN_PORT} exec dotnet /dotnet/example.dll"