Skip to content

Commit 4209641

Browse files
accountingservice-fix-instrumentation (open-telemetry#1791)
1 parent 8a86840 commit 4209641

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/accountingservice/Dockerfile

+20-11
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,32 @@
33

44
FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:8.0 AS builder
55
ARG TARGETARCH
6+
ARG BUILD_CONFIGURATION=Release
7+
WORKDIR /src
8+
COPY ["/src/accountingservice/", "AccountingService/"]
9+
COPY ["/pb/demo.proto", "AccountingService/proto/"]
10+
RUN dotnet restore "./AccountingService/AccountingService.csproj" -r linux-musl-$TARGETARCH
11+
WORKDIR "/src/AccountingService"
612

7-
WORKDIR /usr/src/app/
13+
RUN dotnet build "./AccountingService.csproj" -r linux-musl-$TARGETARCH -c $BUILD_CONFIGURATION -o /app/build
814

9-
COPY ./src/accountingservice/ ./
10-
COPY ./pb/ ./proto/
11-
12-
RUN dotnet restore "./AccountingService.csproj" -r linux-musl-$TARGETARCH
15+
# -----------------------------------------------------------------------------
1316

14-
RUN dotnet publish "./AccountingService.csproj" -r linux-musl-$TARGETARCH --no-restore -o /accountingservice
17+
FROM builder AS publish
18+
ARG BUILD_CONFIGURATION=Release
19+
RUN dotnet publish "./AccountingService.csproj" --use-current-runtime -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
1520

1621
# -----------------------------------------------------------------------------
1722

1823
FROM mcr.microsoft.com/dotnet/aspnet:8.0
19-
20-
WORKDIR /usr/src/app/
21-
COPY --from=builder /accountingservice/ ./
22-
23-
ENV DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE=false
24+
USER app
25+
WORKDIR /app
26+
COPY --from=publish /app/publish .
27+
28+
USER root
29+
RUN mkdir -p "/var/log/opentelemetry/dotnet"
30+
RUN chown app "/var/log/opentelemetry/dotnet"
31+
RUN chown app "/app/instrument.sh"
32+
USER app
2433

2534
ENTRYPOINT ["./instrument.sh", "dotnet", "AccountingService.dll"]

0 commit comments

Comments
 (0)