From 2e549b230d3c00f33172bb85f123a1de116e55e1 Mon Sep 17 00:00:00 2001 From: JustMe Date: Mon, 5 Oct 2026 02:24:15 +0800 Subject: [PATCH] build: use ASP.NET runtime for backend images --- ci/release-linux.sh | 10 +++++++--- docs/deployment.md | 2 +- packaging/container/Backend.Containerfile | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ci/release-linux.sh b/ci/release-linux.sh index 9de737d..460d20c 100644 --- a/ci/release-linux.sh +++ b/ci/release-linux.sh @@ -63,7 +63,11 @@ publish_aot() { publish_aot agent agent/src/Monitor.Agent "$output/agent" publish_aot probe probe/src/Monitor.Probe "$output/probe" publish_aot fleet-enroll fleet/tools/fleet-enroll "$output/fleet-enroll" -publish_aot backend src/Monitor.Backend "$output/backend" +(cd "$root/backend" && dotnet publish src/Monitor.Backend \ + -c Release --no-self-contained \ + -p:UseAppHost=false -p:OpenApiGenerateDocuments=false \ + --artifacts-path "$build_root" \ + -o "$output/backend") package_node() { local role="$1" stage="$stage_root/$1" @@ -112,8 +116,8 @@ upload_package() { package_node agent package_node probe -# The .NET runtime-deps image is a multi-arch OCI base. The Containerfile does -# not execute target-platform commands, so Buildah can assemble either image. +# The ASP.NET runtime image is multi-arch. The Containerfile does not execute +# target-platform commands, so Buildah can assemble either image. container_context="$root/.release/container/linux-$arch" mkdir -p "$container_context/app" "$container_context/data" cp -a "$output/backend/." "$container_context/app/" diff --git a/docs/deployment.md b/docs/deployment.md index be9c0b3..bc91602 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -22,7 +22,7 @@ NativeAOT 不能交叉编译到别的操作系统;MIPS 不支持(见 `projec ## Backend 容器 -Backend 使用 OCI 标准镜像,通过 `registry.oeo.one/monitor/monitor-backend:` 分发,支持 `linux/amd64` 和 `linux/arm64`。容器基于 .NET 10 `runtime-deps` noble-chiseled-extra 镜像,以非 root 用户运行,在 `8080/tcp` 提供 HTTP 服务;数据库和原始数据统一写入 `/data`。`extra` 变体带 IANA 时区数据,供按时区查询使用。将 `/data` 挂载为持久卷,并在反向代理处配置 HTTPS。 +Backend 使用 OCI 标准镜像,通过 `registry.oeo.one/monitor/monitor-backend:` 分发,支持 `linux/amd64` 和 `linux/arm64`。容器基于 .NET 10 ASP.NET noble-chiseled-extra 运行时镜像,以非 root 用户运行,在 `8080/tcp` 提供 HTTP 服务;数据库和原始数据统一写入 `/data`。`extra` 变体带 IANA 时区数据,供按时区查询使用。将 `/data` 挂载为持久卷,并在反向代理处配置 HTTPS。 在部署目录保存此仓库的 `compose.yaml`,先通过部署平台的环境变量或密钥管理设置 `MONITOR_ADMIN_PASSWORD`(可选设置 `MONITOR_ADMIN_USER`、`MONITOR_VERSION`),然后启动: diff --git a/packaging/container/Backend.Containerfile b/packaging/container/Backend.Containerfile index cc36afb..2bde19a 100644 --- a/packaging/container/Backend.Containerfile +++ b/packaging/container/Backend.Containerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-noble-chiseled-extra +FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled-extra ARG APP_VERSION=unknown LABEL org.opencontainers.image.title="Monitor Backend" \ @@ -17,4 +17,4 @@ ENV ASPNETCORE_HTTP_PORTS=8080 \ USER 1654:1654 VOLUME ["/data"] EXPOSE 8080 -ENTRYPOINT ["/app/monitor-backend"] +ENTRYPOINT ["dotnet", "/app/monitor-backend.dll"]