Skip to content

Instantly share code, notes, and snippets.

@MikeGoldsmith
Created March 28, 2020 21:41
Show Gist options
  • Save MikeGoldsmith/7c90017a41ab96b1406aec9054e383e3 to your computer and use it in GitHub Desktop.
Save MikeGoldsmith/7c90017a41ab96b1406aec9054e383e3 to your computer and use it in GitHub Desktop.
dd-trace-dotnet sample dockerfile
# https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /source
# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# copy everything else and build app
COPY . ./
WORKDIR /source
RUN dotnet publish -c release -o /app --no-restore
# final stage/image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
WORKDIR /app
COPY --from=build /app ./
# Set up Datadog APM
ARG TRACER_VERSION=1.14.2
RUN mkdir -p /var/log/datadog
RUN mkdir -p /opt/datadog
RUN curl -LO https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb
RUN dpkg -i ./datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb
# Set up .NET profiling
ENV CORECLR_ENABLE_PROFILING=1
ENV CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8}
ENV CORECLR_PROFILER_PATH=/opt/datadog/Datadog.Trace.ClrProfiler.Native.so
# Set up DataDog / LightStep
ENV DD_INTEGRATIONS=/opt/datadog/integrations.json
ENV DD_DOTNET_TRACER_HOME=/opt/datadog
ENV DD_TRACE_AGENT_URL=https://ingest.lightstep.com:443
ENV DD_SERVICE_NAME=test-webapp
ENV DD_TRACE_GLOBAL_TAGS=lightstep.access_token:{LS_ACCESS_TOKEN}
CMD ["dotnet", "test-webapp.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment