SeaLights .NET Core agent - Sample Docker Files

docker file

FROM mcr.microsoft.com/dotnet/aspnet:6.0 # Sealights - copy agent, token and custom entry point COPY --from=publish /tmp/sl-dotnet-agent /tmp/sl-dotnet-agent COPY ["SeaLights/sltoken.txt", "/tmp/sl-dotnet-agent"] COPY ["SeaLights/docker_entrypoint.sh", "/app/publish"] WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["/app/docker_entrypoint.sh"]

entry point

#!/bin/sh echo Will start the app with Sealights export SL_LogLevel='6' export SL_LogDir='/tmp/sl_logs/' dotnet /tmp/sl-dotnet-agent/SL.DotNet.dll run --instrumentationMode coverage --buildSessionIdFile /tmp/sl-dotnet-agent/buildSessionId.txt --target dotnet --workingDir /app --targetArgs "MyApp.dll" --logAppendFile true --logEnabled true --logFilename "/tmp/sl_logs/collector

Alpine-based docker file for a self-contained app

# https://mcr.microsoft.com/v2/dotnet/runtime-deps/tags/list FROM mcr.microsoft.com/dotnet/runtime-deps:6.0.3-alpine3.15-amd64 WORKDIR / ... # Sealights - install prereq, agent, token, bsid RUN mkdir -p /sealights/{agent,logs} RUN wget -nv -O sealights-dotnet-agent-alpine.tar.gz https://agents.sealights.co/dotnetcore/latest/sealights-dotnet-agent-alpine-self-contained.tar.gz RUN tar -xzf ./sealights-dotnet-agent-alpine.tar.gz --directory /sealights/agent COPY ["SeaLights/sltoken.txt", "/sealights/"] COPY ["SeaLights/buildSessionId.txt", "/sealights/"] RUN chmod -R 777 /sealights WORKDIR /app COPY --from=builder /cartservice . ENTRYPOINT ["/sealights/agent/SL.DotNet run --instrumentationMode coverage --buildSessionIdFile /sealights/buildSessionId.txt --tokenFile /sealights/sltoken.txt --workingDir /app --target /app/cartservice"]

To enable SL logs append to the ENTRYPOINT command the following parameters: --profilerLogDir /sealights/logs --profilerLogLevel 6 --logAppendFile true --logEnabled true --logFilename /sealights/logs/collector