Skip to content

Commit 1bd2c1c

Browse files
hhhhsc701root
andauthored
Enhance image builds and monitoring with no-cache and cleanup (#3344)
* Use CCS tag for mainland pushes * Add no-cache support to image builds * Revamp rollout checksums for env and image changes * Add root build wrapper for image and package builds * Sync monitoring defaults and env generation * Harden monitoring deploy and uninstall cleanup * Unify monitoring provider handling in deploy scripts * Clean up stale monitoring services during deployment * Restrict monitoring dashboard to superusers * Restrict monitoring dashboard to superusers * Relocate monitoring env files to deploy/env * Unify monitoring env handling for deploys * Show image tag examples in deployment source selector * 同步修改文档 * Refactor agent generation workflow * Add interactive deploy config mode * Enable default config mode in offline deploy wrapper * Stop persisting appVersion in deployment config * Add defaults mode to deploy wrappers --------- Co-authored-by: root <root@DESKTOP-UARO3HF.localdomain> Co-authored-by: hhhhsc <name>
1 parent 5c78432 commit 1bd2c1c

49 files changed

Lines changed: 2893 additions & 1070 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ assets/
6262
.Spotlight-V100
6363
.Trashes
6464
ehthumbs.db
65-
Thumbs.db
65+
Thumbs.db

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ docker/openssh-server
2020
docker/volumes/db/data
2121
docker/.env
2222
docker/.env.generated
23-
deploy/docker/assets/monitoring/monitoring.env
23+
deploy/env/monitoring.env
2424
docker/.run
2525
docker/deploy.options
2626
k8s/helm/deploy.options
@@ -84,4 +84,4 @@ _doc/
8484
/deploy/env/.env
8585
/deploy/env/.env.bak
8686

87-
agent_repository_frontend
87+
agent_repository_frontend

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ cd nexent
5050
bash deploy.sh docker
5151
```
5252

53-
The root `deploy.sh` only forwards to the target deploy script; the native Docker implementation is `bash deploy/docker/deploy.sh`. The Docker and Kubernetes deploy scripts share the same deployment configuration model. Interactive runs show Bash TUI menus for component selection, port policy, and image source. `infrastructure` is required; `application`, `data-process`, and `supabase` are selected by default and can be disabled when you want a smaller deployment. Use `b`/Backspace to return to the previous TUI step and `q` to quit. Non-interactive runs can pass the same choices with `--version`, `--components`, `--port-policy development|production`, and `--image-source general|mainland|local-latest`. Successful deployments save non-sensitive choices to each deploy directory's `deploy.options` for reuse on the next run.
53+
The root `deploy.sh` only forwards to the target deploy script; the native Docker implementation is `bash deploy/docker/deploy.sh`. The Docker and Kubernetes deploy scripts share the same deployment configuration model. Interactive runs show Bash TUI menus for component selection, port policy, and image source. `infrastructure` is required; `application`, `data-process`, and `supabase` are selected by default and can be disabled when you want a smaller deployment. Use `b`/Backspace to return to the previous TUI step and `q` to quit. Use `--defaults` to skip the TUI and deploy with saved `deploy.options` or built-in defaults. Non-interactive runs can also pass the same choices with `--version`, `--components`, `--port-policy development|production`, and `--image-source general|mainland|local-latest`. Successful deployments save non-sensitive choices to each deploy directory's `deploy.options` for reuse on the next run.
5454

55-
Docker and Kubernetes both use `deploy/env/.env` as the runtime configuration file. Existing `deploy/env/.env` is kept as-is. If it does not exist, the deploy scripts first reuse `docker/.env`, then fall back to `deploy/env/.env.example`.
55+
Docker and Kubernetes both use `deploy/env/.env` as the runtime configuration file. Existing `deploy/env/.env` is kept as-is. If it does not exist, the deploy scripts first reuse `docker/.env`, then fall back to `deploy/env/.env.example`. Monitoring-specific settings are generated from `deploy/env/monitoring.env.example` into `deploy/env/monitoring.env`.
5656

5757
Docker uninstall is handled by `bash uninstall.sh docker`. It can preserve or delete data volumes: run it interactively, pass `--delete-volumes true|false`, or use `bash uninstall.sh docker delete-all` to remove containers and persistent data.
5858

59-
Offline image packages can be built with `bash deploy/offline/build_offline_package.sh --target docker --compress true`. The package includes image tar files, `load-images.sh`, root deploy/uninstall entrypoints, deployment scripts, SQL files, `manifest.yaml`, and `checksums.txt`; deploy it with `bash deploy.sh --load-images docker ...` on the target host.
59+
Offline image packages can be built with `bash build.sh --package --target docker --compress true` or `bash deploy/offline/build_offline_package.sh --target docker --compress true`. The package includes image tar files, `load-images.sh`, root deploy/uninstall entrypoints, deployment scripts, SQL files, `manifest.yaml`, and `checksums.txt`. Package deploys use saved `deploy.options` or built-in defaults without opening the TUI; add `--config` to configure interactively. Deploy with `bash deploy.sh --load-images docker ...` on the target host.
6060

6161
For detailed deployment instructions, see [Docker Installation](https://modelengine-group.github.io/nexent/en/quick-start/installation.html).
6262

README_CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ cd nexent
5050
bash deploy.sh docker
5151
```
5252

53-
根目录 `deploy.sh` 只负责转发到目标部署脚本;Docker 真实实现为 `bash deploy/docker/deploy.sh`。Docker 和 Kubernetes 使用同一套部署配置模型;交互式运行会通过 Bash TUI 选择组件、端口策略和镜像源。`infrastructure` 必选,`application``data-process``supabase` 默认选中,也可以取消以部署更小的组合。非交互部署可传入 `--version``--components``--port-policy development|production``--image-source general|mainland|local-latest`
53+
根目录 `deploy.sh` 只负责转发到目标部署脚本;Docker 真实实现为 `bash deploy/docker/deploy.sh`。Docker 和 Kubernetes 使用同一套部署配置模型;交互式运行会通过 Bash TUI 选择组件、端口策略和镜像源。`infrastructure` 必选,`application``data-process``supabase` 默认选中,也可以取消以部署更小的组合。使用 `--defaults` 可跳过 TUI,并复用已保存的 `deploy.options` 或内置默认值。非交互部署也可传入 `--version``--components``--port-policy development|production``--image-source general|mainland|local-latest`
5454

55-
Docker 与 Kubernetes 统一使用 `deploy/env/.env` 作为运行配置文件;已有 `deploy/env/.env` 会原样保留。如果 `deploy/env/.env` 不存在,部署脚本会优先复用已有的 `docker/.env`,再回退到 `deploy/env/.env.example`
55+
Docker 与 Kubernetes 统一使用 `deploy/env/.env` 作为运行配置文件;已有 `deploy/env/.env` 会原样保留。如果 `deploy/env/.env` 不存在,部署脚本会优先复用已有的 `docker/.env`,再回退到 `deploy/env/.env.example`监控相关配置会从 `deploy/env/monitoring.env.example` 生成到 `deploy/env/monitoring.env`
5656

5757
Docker 卸载入口为 `bash uninstall.sh docker`,默认交互确认是否删除持久化数据;也可以通过 `--delete-volumes true|false` 控制,或使用 `bash uninstall.sh docker delete-all` 同时删除容器和持久化数据。
5858

59-
离线镜像包可通过 `bash deploy/offline/build_offline_package.sh --target docker --compress true` 构建。包内包含镜像 tar、`load-images.sh`、根目录部署/卸载入口、部署脚本、SQL 文件、`manifest.yaml``checksums.txt`在目标机器上使用 `bash deploy.sh --load-images docker ...` 加载镜像并部署。
59+
离线镜像包可通过 `bash build.sh --package --target docker --compress true``bash deploy/offline/build_offline_package.sh --target docker --compress true` 构建。包内包含镜像 tar、`load-images.sh`、根目录部署/卸载入口、部署脚本、SQL 文件、`manifest.yaml``checksums.txt`。包内部署会复用已保存的 `deploy.options` 或内置默认值,默认不进入 TUI;添加 `--config` 可交互配置。在目标机器上使用 `bash deploy.sh --load-images docker ...` 加载镜像并部署。
6060

6161
详细部署指南请参考 [Docker 安装部署](https://modelengine-group.github.io/nexent/zh/quick-start/installation.html)
6262

build.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
DEPLOYMENT_COMMON="$SCRIPT_DIR/deploy/common/common.sh"
7+
8+
if [ -f "$DEPLOYMENT_COMMON" ]; then
9+
# shellcheck source=/dev/null
10+
source "$DEPLOYMENT_COMMON"
11+
fi
12+
[ -n "${DEPLOYMENT_LANGUAGE:-}" ] || DEPLOYMENT_LANGUAGE="en"
13+
14+
usage() {
15+
if [ "$DEPLOYMENT_LANGUAGE" = "zh" ]; then
16+
cat <<'USAGE'
17+
用法:
18+
bash build.sh [镜像构建选项]
19+
bash build.sh --package [离线包构建选项]
20+
21+
镜像构建会转发到:deploy/images/build.sh
22+
离线包构建会转发到:deploy/offline/build_offline_package.sh
23+
24+
常用示例:
25+
bash build.sh --main --version latest --dry-run
26+
bash build.sh --package --version latest --target docker --dry-run
27+
28+
更多选项:
29+
bash deploy/images/build.sh --help
30+
bash deploy/offline/build_offline_package.sh --help
31+
USAGE
32+
return
33+
fi
34+
35+
cat <<'USAGE'
36+
Usage:
37+
bash build.sh [image build options]
38+
bash build.sh --package [offline package options]
39+
40+
Image builds are forwarded to: deploy/images/build.sh
41+
Offline package builds are forwarded to: deploy/offline/build_offline_package.sh
42+
43+
Examples:
44+
bash build.sh --main --version latest --dry-run
45+
bash build.sh --package --version latest --target docker --dry-run
46+
47+
More options:
48+
bash deploy/images/build.sh --help
49+
bash deploy/offline/build_offline_package.sh --help
50+
USAGE
51+
}
52+
53+
case "${1:-}" in
54+
--help|-h)
55+
usage
56+
exit 0
57+
;;
58+
esac
59+
60+
if [ "${1:-}" = "--package" ]; then
61+
shift
62+
exec bash "$SCRIPT_DIR/deploy/offline/build_offline_package.sh" "$@"
63+
fi
64+
65+
exec bash "$SCRIPT_DIR/deploy/images/build.sh" "$@"

deploy.sh

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,73 @@
33
set -euo pipefail
44

55
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
DEPLOYMENT_COMMON="$SCRIPT_DIR/deploy/common/common.sh"
7+
8+
if [ -f "$DEPLOYMENT_COMMON" ]; then
9+
# shellcheck source=/dev/null
10+
source "$DEPLOYMENT_COMMON"
11+
fi
12+
[ -n "${DEPLOYMENT_LANGUAGE:-}" ] || DEPLOYMENT_LANGUAGE="en"
13+
DEPLOY_WRAPPER_DEFAULT_CONFIG_MODE=""
614

715
usage() {
16+
if [ "$DEPLOYMENT_LANGUAGE" = "zh" ]; then
17+
cat <<'USAGE'
18+
用法:
19+
bash deploy.sh [--load-images] [--config|--defaults] docker [Docker 部署选项]
20+
bash deploy.sh [--load-images] [--config|--defaults] k8s [K8s 部署选项]
21+
22+
USAGE
23+
if [ "$DEPLOY_WRAPPER_DEFAULT_CONFIG_MODE" = "defaults" ]; then
24+
cat <<'USAGE'
25+
此离线包入口默认复用保存配置或内置默认值部署,不进入交互界面。
26+
添加 --config 可进入交互式部署配置界面。
27+
实现:deploy/deploy.sh
28+
29+
USAGE
30+
else
31+
cat <<'USAGE'
32+
此根入口只转发到目标专用部署脚本。
33+
实现:deploy/deploy.sh
34+
35+
USAGE
36+
fi
37+
cat <<'USAGE'
38+
选项:
39+
--load-images 部署前从 ./images 加载 Docker 镜像 tar 文件。
40+
默认关闭。
41+
--config 进入交互式部署配置界面。
42+
--defaults 复用保存配置或内置默认值,跳过交互界面。
43+
USAGE
44+
return
45+
fi
46+
847
cat <<'USAGE'
948
Usage:
10-
bash deploy.sh [--load-images] docker [docker deploy options]
11-
bash deploy.sh [--load-images] k8s [k8s deploy options]
49+
bash deploy.sh [--load-images] [--config|--defaults] docker [docker deploy options]
50+
bash deploy.sh [--load-images] [--config|--defaults] k8s [k8s deploy options]
51+
52+
USAGE
53+
if [ "$DEPLOY_WRAPPER_DEFAULT_CONFIG_MODE" = "defaults" ]; then
54+
cat <<'USAGE'
55+
This offline entrypoint deploys with saved configuration or built-in defaults by default.
56+
Add --config to open the interactive deployment configuration.
57+
Implementation: deploy/deploy.sh
1258
59+
USAGE
60+
else
61+
cat <<'USAGE'
1362
This root entrypoint only forwards to the target-specific deploy script.
1463
Implementation: deploy/deploy.sh
1564
65+
USAGE
66+
fi
67+
cat <<'USAGE'
1668
Options:
1769
--load-images Load Docker image tar files from ./images before deploying.
1870
Defaults to off.
71+
--config Open the interactive deployment configuration.
72+
--defaults Use saved configuration or built-in defaults and skip TUI.
1973
USAGE
2074
}
2175

@@ -25,6 +79,7 @@ if [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ] || [ $# -eq 0 ]; then
2579
fi
2680

2781
LOAD_IMAGES="false"
82+
DEPLOY_CONFIG_MODE="$DEPLOY_WRAPPER_DEFAULT_CONFIG_MODE"
2883
FORWARD_ARGS=()
2984

3085
while [ $# -gt 0 ]; do
@@ -33,6 +88,14 @@ while [ $# -gt 0 ]; do
3388
LOAD_IMAGES="true"
3489
shift
3590
;;
91+
--config)
92+
DEPLOY_CONFIG_MODE="tui"
93+
shift
94+
;;
95+
--defaults)
96+
DEPLOY_CONFIG_MODE="defaults"
97+
shift
98+
;;
3699
*)
37100
FORWARD_ARGS+=("$1")
38101
shift
@@ -48,10 +111,18 @@ fi
48111
if [ "$LOAD_IMAGES" = "true" ]; then
49112
LOAD_SCRIPT="$SCRIPT_DIR/load-images.sh"
50113
if [ ! -f "$LOAD_SCRIPT" ]; then
51-
echo "Error: --load-images requires $LOAD_SCRIPT" >&2
114+
if [ "$DEPLOYMENT_LANGUAGE" = "zh" ]; then
115+
echo "错误:--load-images 需要 $LOAD_SCRIPT" >&2
116+
else
117+
echo "Error: --load-images requires $LOAD_SCRIPT" >&2
118+
fi
52119
exit 1
53120
fi
54121
bash "$LOAD_SCRIPT"
55122
fi
56123

124+
if [ -n "$DEPLOY_CONFIG_MODE" ]; then
125+
NEXENT_DEPLOY_CONFIG_MODE="$DEPLOY_CONFIG_MODE" exec bash "$SCRIPT_DIR/deploy/deploy.sh" "${FORWARD_ARGS[@]}"
126+
fi
127+
57128
exec bash "$SCRIPT_DIR/deploy/deploy.sh" "${FORWARD_ARGS[@]}"

0 commit comments

Comments
 (0)