通过 Dockerfile 在 Docker 容器中安装 APM Insight .NET 代理
在 Docker 容器中安装 .NET 代理与在 Windows 上安装标准 .NET 代理的方式相同。您需要配置 DockerFile 来完成安装。
在 Windows Docker 容器中安装 .NET 代理
以下是在 Windows Docker 容器中配置 .NET 代理的示例。
FROM mcr.microsoft.com/dotnet/framework/aspnet
# Publish your application
COPY your app to be published /inetpub/wwwroot
# Download the APM Insight .NET agent installer
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\
Invoke-WebRequest "https://staticdownloads.site24x7.com/apminsight/agents/apminsight-dotnetagent.msi" -UseBasicParsing -OutFile "apminsight-dotnetagent.msi"
# Install the APM Insight .NET agent
RUN Start-Process -Wait -FilePath msiexec -ArgumentList /i, "apminsight-dotnetagent.msi", /qn, editconfig=false, useappfilters=false, license.key=YOUR_LICENSE_KEY
# Remove the APM Insight .NET agent installer
RUN Remove-Item "apminsight-dotnetagent.msi"
# Set your application name
ENV SITE24X7_APP_NAME=YOUR_APP_NAME
在 Linux Docker 容器中安装 .NET 代理
以下是在 Linux Docker 容器中配置 .NET 代理的示例。
# Use Linux-based ASP.NET runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
# Set working directory
WORKDIR /app
# Copy your published app
COPY your_app_published_folder/ . # replace with your actual published app folder path
# Use wget to download and install APM Insight agent
RUN apt-get update && \
apt-get install -y wget ca-certificates unzip && \
wget https://staticdownloads.site24x7.com/apminsight/agents/dotnet/apminsight-dotnetcoreagent-linux.sh && \
chmod +x apminsight-dotnetcoreagent-linux.sh && \
./apminsight-dotnetcoreagent-linux.sh -Destination "/opt/apminsight/dotnet" -LicenseKey "YOUR_LICENSE_KEY" && \
rm apminsight-dotnetcoreagent-linux.sh
# set the env variables for the APM Insight Agent
ENV SITE24X7_APP_NAME=YOUR_APP_NAME
ENV S247_LICENSE_KEY=YOUR_LICENSE_KEY
ENV CORECLR_ENABLE_PROFILING=1
ENV CORECLR_PROFILER="{9D363A5F-ED5F-4AAC-B456-75AFFA6AA0C8}"
ENV CORECLR_SITE24X7_HOME="/opt/apminsight/dotnet/ApmInsightDotNetCoreAgent"
ENV CORECLR_PROFILER_PATH_64="/opt/apminsight/dotnet/ApmInsightDotNetCoreAgent/x64/libClrProfilerAgent.so"
ENV CORECLR_PROFILER_PATH_32="/opt/apminsight/dotnet/ApmInsightDotNetCoreAgent/x86/libClrProfilerAgent.so"
ENV DOTNET_STARTUP_HOOKS="/opt/apminsight/dotnet/ApmInsightDotNetCoreAgent/netstandard2.0/DotNetAgent.Loader.dll"
ENV MANAGEENGINE_COMMUNICATION_MODE="direct"
# Expose the required for your app port (adjust if needed)
EXPOSE 80
# Set entrypoint
ENTRYPOINT ["dotnet", "your_app.dll"] # replace with your actual app DLL
注意
- 将 YOUR_LICENSE_KEY 替换为您实际的 Site24x7 APM Insight 许可证密钥。
- 将 YOUR_APP_NAME 替换为您的应用程序名称。
相关文章
如何在 Docker 容器中安装各类 APM Insight 代理
Java | PHP | Node.js | Python
如何在 Kubernetes 环境中安装各类 APM Insight 代理
Java | .NET | PHP | Node.js | Python
