FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base

# Download OpenTelemetry .NET auto-instrumentation
RUN apt-get update && apt-get install -y curl unzip && \
    curl -sSL https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/download/v1.7.0/opentelemetry-dotnet-instrumentation-linux-glibc-x64.zip -o /tmp/otel.zip && \
    unzip /tmp/otel.zip -d /opt/otel-dotnet && \
    rm /tmp/otel.zip && \
    chmod -R 755 /opt/otel-dotnet

# Create volume for sharing instrumentation files
VOLUME /otel-dotnet

CMD ["cp", "-r", "/opt/otel-dotnet/.", "/otel-dotnet/"]
