Installing the NewRelic .NET agent on an Alpine Docker image
Alpine is a small Linux distribution, commonly used in containers like Docker due to its size.
In order to install the .NET agent on an Alpine, you need to modify your dockerfile to download the compressed agent binaries and manually install them. This involves a bit of file, folder and permission manipulation, as well as setting up a symlink.
In your Dockerfile, add the following lines:
# Prepare required directories for Newrelic installation
RUN mkdir -p /var/log/newrelic /var/log/newrelic/dotnet && \
chmod -R g+ws /tmp /var/log/newrelic/ && \
chown -R 1001:0 /tmp /var/log/newrelic/ && \
# Download and install Newrelic binary
cd /tmp && wget NEWRELIC_AGENT_DOWNLOAD_URL && \
tar xzf newrelic*.tar.gz && \
mv newrelic-netcore20-agent /usr/local && \
mkdir /usr/local/newrelic-netcore20-agent/logs && \
chmod -R o+w /usr/local/newrelic-netcore20-agent/logs && \
ln -s /usr/local/newrelic-netcore20-agent/logs /var/log/newrelic/dotnet && \
rm newrelic*.tar.gz
# Enable the agent
ENV CORECLR_NEWRELIC_HOME=/usr/local/newrelic-netcore20-agent \
CORECLR_ENABLE_PROFILING=1 \
CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A} \
CORECLR_NEWRELIC_HOME=/usr/local/newrelic-netcore20-agent \
CORECLR_PROFILER_PATH=/usr/local/newrelic-netcore20-agent/libNewRelicProfiler.so \
NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY \
NEW_RELIC_APP_NAME=YOUR_APP_NAME
Replace the NEWRELIC_AGENT_DOWNLOAD_URL placeholder with the URL to the desired NewRelic tarball for Linux, environment variable placeholders YOUR_LICENSE_KEY with your NewRelic license key and YOUR_APP_NAME with the name you want to set up your application with.
Once your application gets traffic, your application name should show in the New Relic UI.
Newest Posts
- Now Generating URL Slugs With Natural Language Processing!
- Safe Storage of App Secrets in Python Development
- Automate All The Things: A Manifesto for Building Better Teams
- Preserve commit history when moving files across Git repositories
- Publishing a Jekyll site to a separate Github Pages repository using Github Actions