From 9fe50f97b968b3f538ee0343a131b81f33df0e56 Mon Sep 17 00:00:00 2001 From: Juliano Costa Date: Sun, 24 Nov 2024 21:41:00 +0100 Subject: [PATCH] accountingservice-fix-instrumentation --- src/accountingservice/Dockerfile | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/accountingservice/Dockerfile b/src/accountingservice/Dockerfile index a6b0e9bfb9..8524db57cd 100644 --- a/src/accountingservice/Dockerfile +++ b/src/accountingservice/Dockerfile @@ -3,23 +3,32 @@ FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:8.0 AS builder ARG TARGETARCH +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["/src/accountingservice/", "AccountingService/"] +COPY ["/pb/demo.proto", "AccountingService/proto/"] +RUN dotnet restore "./AccountingService/AccountingService.csproj" -r linux-musl-$TARGETARCH +WORKDIR "/src/AccountingService" -WORKDIR /usr/src/app/ +RUN dotnet build "./AccountingService.csproj" -r linux-musl-$TARGETARCH -c $BUILD_CONFIGURATION -o /app/build -COPY ./src/accountingservice/ ./ -COPY ./pb/ ./proto/ - -RUN dotnet restore "./AccountingService.csproj" -r linux-musl-$TARGETARCH +# ----------------------------------------------------------------------------- -RUN dotnet publish "./AccountingService.csproj" -r linux-musl-$TARGETARCH --no-restore -o /accountingservice +FROM builder AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./AccountingService.csproj" --use-current-runtime -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false # ----------------------------------------------------------------------------- FROM mcr.microsoft.com/dotnet/aspnet:8.0 - -WORKDIR /usr/src/app/ -COPY --from=builder /accountingservice/ ./ - -ENV DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE=false +USER app +WORKDIR /app +COPY --from=publish /app/publish . + +USER root +RUN mkdir -p "/var/log/opentelemetry/dotnet" +RUN chown app "/var/log/opentelemetry/dotnet" +RUN chown app "/app/instrument.sh" +USER app ENTRYPOINT ["./instrument.sh", "dotnet", "AccountingService.dll"]