github.com/grafana/pyroscope@v1.18.0/examples/language-sdk-instrumentation/dotnet/rideshare/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-bookworm-slim 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-x64 --no-self-contained
    23  
    24  # This fetches the SDK
    25  FROM --platform=linux/amd64 pyroscope/pyroscope-dotnet:0.13.0-glibc 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-noble-chiseled-extra
    29  
    30  WORKDIR /dotnet
    31  
    32  # chiseled images don't include CA certs by default
    33  COPY --from=build /etc/ssl/certs /etc/ssl/certs
    34  
    35  COPY --from=sdk /Pyroscope.Profiler.Native.so ./Pyroscope.Profiler.Native.so
    36  COPY --from=sdk /Pyroscope.Linux.ApiWrapper.x64.so ./Pyroscope.Linux.ApiWrapper.x64.so
    37  COPY --from=build /dotnet/ ./
    38  
    39  
    40  ENV CORECLR_ENABLE_PROFILING=1
    41  ENV CORECLR_PROFILER={BD1A650D-AC5D-4896-B64F-D6FA25D6B26A}
    42  ENV CORECLR_PROFILER_PATH=/dotnet/Pyroscope.Profiler.Native.so
    43  ENV LD_PRELOAD=/dotnet/Pyroscope.Linux.ApiWrapper.x64.so
    44  ENV LD_LIBRARY_PATH=/dotnet
    45  
    46  # point OpenSSL to the CA certificates bundle
    47  ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
    48  
    49  ENV PYROSCOPE_APPLICATION_NAME=rideshare.dotnet.app
    50  ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040
    51  ENV PYROSCOPE_LOG_LEVEL=debug
    52  ENV PYROSCOPE_PROFILING_ENABLED=1
    53  ENV PYROSCOPE_PROFILING_ALLOCATION_ENABLED=true
    54  ENV PYROSCOPE_PROFILING_CONTENTION_ENABLED=true
    55  ENV PYROSCOPE_PROFILING_EXCEPTION_ENABLED=true
    56  ENV PYROSCOPE_PROFILING_HEAP_ENABLED=true
    57  ENV RIDESHARE_LISTEN_PORT=5000
    58  ENV ASPNETCORE_URLS=http://*:5000
    59  
    60  
    61  CMD ["/dotnet/example.dll"]