FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS builder
ARG AGENT_VERSION=1.19.0
WORKDIR /app
COPY . .
RUN dotnet restore ./API/app/app.csproj
WORKDIR /app/API/app
RUN dotnet publish "app.csproj" --no-restore -c Release -o /app/publish
RUN apk add curl
RUN apk update && apk add unzip
RUN curl -L -o elastic_apm_profiler_${AGENT_VERSION}.zip https://github.com/elastic/apm-agent-dotnet/releases/download/v${AGENT_VERSION}/elastic_apm_profiler_${AGENT_VERSION}.zip && \
unzip elastic_apm_profiler_${AGENT_VERSION}.zip -d /elastic_apm_profiler_${AGENT_VERSION}
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS runtime
ARG AGENT_VERSION=1.19.0
WORKDIR /app
COPY --from=builder /app/publish /app
COPY --from=builder /elastic_apm_profiler_${AGENT_VERSION} /elastic_apm_profiler
RUN mkdir /profiler_logs
ENV CORECLR_ENABLE_PROFILING=1
ENV CORECLR_PROFILER={FA65FE15-F085-4681-9B20-95E04F6C03CC}
ENV CORECLR_PROFILER_PATH=/elastic_apm_profiler/elastic_apm_profiler_1.19.0/libelastic_apm_profiler.so
ENV ELASTIC_APM_PROFILER_HOME=/elastic_apm_profiler
ENV ELASTIC_APM_PROFILER_INTEGRATIONS=/elastic_apm_profiler/elastic_apm_profiler_1.19.0/integrations.yml
ENV ELASTIC_APM_PROFILER_LOG_DIR=/profiler_logs
ENV ELASTIC_APM_PROFILER_LOG=trace
ENV ELASTIC_APM_SERVICE_NODE_NAME=localhost
RUN apk update && apk upgrade --latest
RUN apk add curl
RUN apk --no-cache upgrade musl
ENV ASPNETCORE_URLS http://*8080
ENV ASPNETCORE_ENVIRONMENT=development
# Required for Time Zone database lookups
RUN apk add --no-cache tzdata
ENV TZ America/Chicago
COPY oracle_cloud /opt
EXPOSE 50051
ENTRYPOINT ["dotnet", "app"]
Container starts fine, but when I don't see any metrics in Elastic APM and if i go to profiler logs, there is nothing there:
/app # ls /profiler_logs/
/app # ls /elastic_apm_profiler/
__MACOSX elastic_apm_profiler_1.19.0
/app # ls /elastic_apm_profiler/elastic_apm_profiler_1.19.0/
LICENSE README integrations.yml net461 netstandard2.0
NOTICE elastic_apm_profiler.dll libelastic_apm_profiler.so netcoreapp3.1
Also I don't see libelastic_apm_profiler.so being loaded into the process:
/app # lsof -p 1 | grep libelastic
/app #
Is something wrong with my Dockerfile setup? I know in documentation example there was plain Alpine image used. Do Microsoft Artifact Registry images require different handling?