FROM mcr.microsoft.com/dotnet/sdk:10.0-noble-aot AS build WORKDIR /src/backend # 构建信息:CI 通过 --build-arg 传入;不传就是空 ARG MONITOR_TAG= ARG MONITOR_COMMIT= ARG MONITOR_BUILT_AT= ENV MONITOR_TAG=$MONITOR_TAG MONITOR_COMMIT=$MONITOR_COMMIT MONITOR_BUILT_AT=$MONITOR_BUILT_AT COPY restore/backend/ ./ RUN dotnet restore agent/src/Monitor.Agent -r linux-x64 --artifacts-path /artifacts \ && dotnet restore fleet/tools/fleet-enroll -r linux-x64 --artifacts-path /artifacts COPY source/backend/ ./ RUN dotnet publish agent/src/Monitor.Agent -m:3 -c Release -r linux-x64 \ --self-contained true --no-restore -p:PublishAot=true -p:UseAotAnywhere=false \ -p:UseAppHost=true -p:StripSymbols=true \ -p:DebugType=none -p:DebugSymbols=false --artifacts-path /artifacts -o /out/agent \ && dotnet publish fleet/tools/fleet-enroll -m:3 -c Release -r linux-x64 \ --self-contained true --no-restore -p:PublishAot=true -p:UseAotAnywhere=false \ -p:UseAppHost=true -p:StripSymbols=true \ -p:DebugType=none -p:DebugSymbols=false --artifacts-path /artifacts -o /out/enroll RUN test -x /out/agent/monitor-agent && test -x /out/enroll/fleet-enroll FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-noble-chiseled-extra ARG APP_VERSION=main LABEL org.opencontainers.image.title="Monitor Agent" \ org.opencontainers.image.description="MyMonitor node agent for Linux" \ org.opencontainers.image.licenses="Apache-2.0" \ org.opencontainers.image.version="$APP_VERSION" COPY --chown=1654:1654 --from=build /out/agent/monitor-agent /usr/local/bin/monitor-agent COPY --chown=1654:1654 --from=build /out/enroll/fleet-enroll /usr/local/bin/fleet-enroll COPY --chown=1654:1654 config/ /etc/monitor/ USER 1654:1654 WORKDIR /etc/monitor VOLUME ["/etc/monitor"] ENTRYPOINT ["/usr/local/bin/monitor-agent"] CMD ["--config", "/etc/monitor/agent.json"]