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