Alpine dockerfile example
See original GitHub issueIs your feature request related to a problem? Please describe. No problem. just wanted to showcase my setup if someone finds it useful
Dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:2.2.401-alpine3.9 AS build-env
WORKDIR /app/src
COPY src/ /app/src/
RUN dotnet publish -o temp -c Release
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2.6-alpine3.9
ENV DD_APM_VERSION=1.9.0
RUN apk --no-cache update \
&& apk add bash make python py-pip libc6-compat gcompat curl
RUN pip install pyyaml
COPY Makefile /app/src/
COPY ./values/*.yaml /app/src/values/
COPY script/parseEnv.py /app/src/script/
COPY --from=build-env app/src/temp /app/src
#Install Datadog APM package
RUN mkdir -p /opt/datadog
RUN curl -L https://github.com/DataDog/dd-trace-dotnet/releases/download/v${DD_APM_VERSION}/datadog-dotnet-apm-${DD_APM_VERSION}.tar.gz \
| tar xzf - -C /opt/datadog
#Setup Datadog APM
ENV CORECLR_ENABLE_PROFILING=1
ENV CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8}
ENV CORECLR_PROFILER_PATH=/opt/datadog/Datadog.Trace.ClrProfiler.Native.so
ENV DD_INTEGRATIONS=/opt/datadog/integrations.json
ENV DD_DOTNET_TRACER_HOME=/opt/datadog
WORKDIR /app/src
CMD ["dotnet", "app.dll"]
app.csproj
<PackageReference Include="Datadog.Trace.ClrProfiler.Managed" Version="1.9.0" />
in startup class
private static void ConfigureDataDogAPM()
{
var settings = TracerSettings.FromDefaultSources();
string appName = Environment.GetEnvironmentVariable("APP_NAME");
settings.ServiceName = appName;
settings.AgentUri = new Uri("http://localhost:8126/");
// disable the AdoNet integration
settings.Integrations["AdoNet"].Enabled = false;
settings.Environment = Environment.GetEnvironmentVariable("ENVIRONMENT");
// create a new Tracer using these settings
var tracer = new Tracer(settings);
// set the global tracer
Tracer.Instance = tracer;
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to Use the Alpine Docker Official Image
The fastest method involves running docker pull alpine from your terminal. This grabs the alpine:latest image (the most current available version) from Docker ......
Read more >Use Docker and Alpine Linux to build lightweight containers
In this Docker and Alpine Linux tutorial, learn how to create a lightweight container ... To add Bash to the Dockerfile, use apk...
Read more >alpine - Official Image
A minimal Docker image based on Alpine Linux with a complete package index and only 5 MB in size!
Read more >Dockerfile tutorial by example - basics and best practices [2018]
An in-depth tutorial on creating your own Docker images with Dockerfile. Detailed examples, videos and Dockerfile best practices.
Read more >docker-alpine/docs/usage.md at master
Here is a full example Dockerfile that installs the Python runtime and some build dependencies: FROM gliderlabs/alpine:3.3 RUN apk add --update-cache ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, @shavo007! This will certainly help others setting up the Tracer on Alpine 3.9.
One bit of feedback: Since v1.8.0, if the
DD_DOTNET_TRACER_HOME
environment is set, theDatadog.Trace.ClrProfiler.Managed
NuGet package is no longer required for .NET Core users, so feel free to remove the<PackageReference>
from thecsproj
project file.@shavo007 That is correct.