# CODE ALREADY IN YOUR DOCKERFILEFROM base AS final# NEW CODE: Copy instrumentation file treeWORKDIR "//home/app/.splunk-otel-dotnet"COPY --from=build /root/.splunk-otel-dotnet/ .# CODE ALREADY IN YOUR DOCKERFILEWORKDIR /appCOPY --from=publish /app/publish .# NEW CODE: copy the entrypoint.sh scriptCOPY entrypoint.sh .# NEW CODE: set OpenTelemetry environment variablesENVOTEL_SERVICE_NAME=helloworld
ENVOTEL_RESOURCE_ATTRIBUTES='deployment.environment=otel-$INSTANCE'# NEW CODE: replace the prior ENTRYPOINT command with the following two linesENTRYPOINT["sh","entrypoint.sh"]CMD["dotnet","helloworld.dll"]
vi での変更を保存するには、escキーを押してコマンドモードに入り、:wq!と入力してからenter/returnキーを押します。
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS baseUSER appWORKDIR /appEXPOSE 8080FROM mcr.microsoft.com/dotnet/sdk:8.0 AS buildARGBUILD_CONFIGURATION=Release
WORKDIR /srcCOPY["helloworld.csproj", "helloworld/"]RUN dotnet restore "./helloworld/./helloworld.csproj"WORKDIR "/src/helloworld"COPY . .RUN dotnet build "./helloworld.csproj" -c $BUILD_CONFIGURATION -o /app/build# NEW CODE: add dependencies for splunk-otel-dotnet-install.shRUN apt-get update &&\
apt-get install -y unzip# NEW CODE: download Splunk OTel .NET installerRUN curl -sSfL https://github.com/signalfx/splunk-otel-dotnet/releases/latest/download/splunk-otel-dotnet-install.sh -O# NEW CODE: install the distributionRUN sh ./splunk-otel-dotnet-install.shFROM build AS publishARGBUILD_CONFIGURATION=Release
RUN dotnet publish "./helloworld.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=falseFROM base AS final# NEW CODE: Copy instrumentation file treeWORKDIR "//home/app/.splunk-otel-dotnet"COPY --from=build /root/.splunk-otel-dotnet/ .WORKDIR /appCOPY --from=publish /app/publish .# NEW CODE: copy the entrypoint.sh scriptCOPY entrypoint.sh .# NEW CODE: set OpenTelemetry environment variablesENVOTEL_SERVICE_NAME=helloworld
ENVOTEL_RESOURCE_ATTRIBUTES='deployment.environment=otel-$INSTANCE'# NEW CODE: replace the prior ENTRYPOINT command with the following two linesENTRYPOINT["sh","entrypoint.sh"]CMD["dotnet","helloworld.dll"]