Skip to content

Commit f28bae8

Browse files
authored
Add offline package compression and update Docker/Kubernetes instructions (#3306)
* Add offline package compression and pull skipping * ✨ Update installation and deployment instructions for Docker and Kubernetes --------- Co-authored-by: hhhhsc <name>
1 parent 2d1c471 commit f28bae8

29 files changed

Lines changed: 744 additions & 212 deletions

.github/workflows/build-offline-package.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,16 @@ jobs:
100100
--include-source "${{ inputs.include_source }}" \
101101
--image-source "${{ inputs.image_source }}" \
102102
--components "${{ inputs.components }}" \
103-
--target "${{ inputs.target }}"
103+
--target "${{ inputs.target }}" \
104+
--compress true
104105
105106
106107
107-
- name: Create zip package
108+
- name: Show zip package
108109
run: |
109110
PACKAGE_NAME="${{ steps.set-vars.outputs.package-name }}"
110111
111-
(cd offline-output && zip -r "../${PACKAGE_NAME}.zip" .)
112-
113-
echo "Package created: ${PACKAGE_NAME}.zip"
112+
echo "Package created by build script: ${PACKAGE_NAME}.zip"
114113
115114
ls -lh "${PACKAGE_NAME}.zip"
116115

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ 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` is selected by default but can be disabled. 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. 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.
5454

55-
Docker and Kubernetes both use the project root `.env` as the runtime configuration file. If it does not exist, the deploy scripts create it from `.env.example` or migrate an existing `docker/.env` once.
55+
Docker and Kubernetes both use the project root `.env` as the runtime configuration file. Existing `.env` is kept as-is. If it does not exist, the deploy scripts first reuse an existing `docker/.env`, then fall back to `.env.example` or `docker/.env.example`.
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.
60+
5961
For detailed deployment instructions, see [Docker Installation](https://modelengine-group.github.io/nexent/en/quick-start/installation.html).
6062

6163
### Kubernetes Deployment (For Enterprise Production)
@@ -68,10 +70,12 @@ cd nexent
6870
bash deploy.sh k8s
6971
```
7072

71-
The native Kubernetes implementation is `bash deploy/k8s/deploy.sh`. It reads the same project root `.env` as Docker and renders explicit values into Helm ConfigMap and Secret overrides. Use `--persistence-mode local|dynamic|existing`, `--storage-class`, `--local-path`, `--local-node-name`, and `--existing-claim-prefix` to control PVC behavior.
73+
The native Kubernetes implementation is `bash deploy/k8s/deploy.sh`. It reads the same project root `.env` as Docker and renders explicit values into Helm ConfigMap and Secret overrides. Use `--persistence-mode local|dynamic|existing`, `--storage-class`/`--sc`, `--local-path`, `--local-node-name`, and `--existing-claim-prefix` to control PVC behavior. Local mode renders `hostPath` PVs and does not require node affinity.
7274

7375
Kubernetes uninstall is handled by `bash uninstall.sh k8s`. It removes the Helm release first, then can optionally delete the namespace and local PV data. Use `--delete-namespace true|false`, `--delete-local-data true|false`, or `bash uninstall.sh k8s delete-all`; pass `--keep-local-data` with `delete-all` to preserve local volume contents.
7476

77+
Kubernetes offline packages use the same builder with `--target k8s` or `--target all`. Run `load-images.sh` on every cluster node that needs the images, or push the loaded images to an internal registry before deploying with the same version and image-source options used during packaging.
78+
7579
For detailed deployment instructions, see [Kubernetes Installation](https://modelengine-group.github.io/nexent/en/quick-start/kubernetes-installation.html).
7680

7781
# ✨ Core Features

README_CN.md

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

53-
根目录 `deploy.sh` 只负责转发到目标部署脚本;Docker 真实实现为 `bash deploy/docker/deploy.sh`。非交互部署可传入 `--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` 默认选中,也可以取消以部署更小的组合。非交互部署可传入 `--version``--components``--port-policy development|production``--image-source general|mainland|local-latest`
5454

55-
Docker 与 Kubernetes 统一使用项目根目录 `.env` 作为运行配置文件;如果不存在,部署脚本会从 `.env.example` 创建,或首次自动迁移已有的 `docker/.env`
55+
Docker 与 Kubernetes 统一使用项目根目录 `.env` 作为运行配置文件;已有 `.env` 会原样保留。如果根目录 `.env` 不存在,部署脚本会优先复用已有的 `docker/.env`,再回退到 `.env.example``docker/.env.example`
56+
57+
Docker 卸载入口为 `bash uninstall.sh docker`,默认交互确认是否删除持久化数据;也可以通过 `--delete-volumes true|false` 控制,或使用 `bash uninstall.sh docker delete-all` 同时删除容器和持久化数据。
58+
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 ...` 加载镜像并部署。
5660

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

@@ -66,10 +70,12 @@ cd nexent
6670
bash deploy.sh k8s
6771
```
6872

69-
Kubernetes 真实实现为 `bash deploy/k8s/deploy.sh`。它会读取同一个根目录 `.env`,并显式渲染为 Helm ConfigMap 和 Secret 覆盖值。PVC 可通过 `--persistence-mode local|dynamic|existing``--storage-class``--local-path``--local-node-name``--existing-claim-prefix` 控制。
73+
Kubernetes 真实实现为 `bash deploy/k8s/deploy.sh`。它会读取同一个根目录 `.env`,并显式渲染为 Helm ConfigMap 和 Secret 覆盖值。PVC 可通过 `--persistence-mode local|dynamic|existing``--storage-class`/`--sc``--local-path``--local-node-name``--existing-claim-prefix` 控制。local 模式会渲染 `hostPath` PV,不再需要 nodeAffinity
7074

7175
根目录卸载入口为 `bash uninstall.sh docker ...``bash uninstall.sh k8s ...`,具体实现仍分别在 `deploy/docker/uninstall.sh``deploy/k8s/uninstall.sh`
7276

77+
Kubernetes 离线包使用同一个构建脚本,传入 `--target k8s``--target all`。部署前需要在每个需要运行 Pod 的节点上执行 `load-images.sh`,或将镜像推送到集群可访问的内部镜像仓库,再使用与打包时一致的版本和镜像源参数部署。
78+
7379
详细部署指南请参考 [Kubernetes 安装部署](https://modelengine-group.github.io/nexent/zh/quick-start/kubernetes-installation.html)
7480

7581
# ✨ 核心特性

deploy.sh

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
77
usage() {
88
cat <<'USAGE'
99
Usage:
10-
bash deploy.sh docker [docker deploy options]
11-
bash deploy.sh k8s [k8s deploy options]
10+
bash deploy.sh [--load-images] docker [docker deploy options]
11+
bash deploy.sh [--load-images] k8s [k8s deploy options]
1212
1313
This root entrypoint only forwards to the target-specific deploy script.
1414
Implementation: deploy/deploy.sh
15+
16+
Options:
17+
--load-images Load Docker image tar files from ./images before deploying.
18+
Defaults to off.
1519
USAGE
1620
}
1721

@@ -20,4 +24,34 @@ if [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ] || [ $# -eq 0 ]; then
2024
exit 0
2125
fi
2226

23-
exec bash "$SCRIPT_DIR/deploy/deploy.sh" "$@"
27+
LOAD_IMAGES="false"
28+
FORWARD_ARGS=()
29+
30+
while [ $# -gt 0 ]; do
31+
case "$1" in
32+
--load-images)
33+
LOAD_IMAGES="true"
34+
shift
35+
;;
36+
*)
37+
FORWARD_ARGS+=("$1")
38+
shift
39+
;;
40+
esac
41+
done
42+
43+
if [ "${#FORWARD_ARGS[@]}" -eq 0 ]; then
44+
usage
45+
exit 0
46+
fi
47+
48+
if [ "$LOAD_IMAGES" = "true" ]; then
49+
LOAD_SCRIPT="$SCRIPT_DIR/load-images.sh"
50+
if [ ! -f "$LOAD_SCRIPT" ]; then
51+
echo "Error: --load-images requires $LOAD_SCRIPT" >&2
52+
exit 1
53+
fi
54+
bash "$LOAD_SCRIPT"
55+
fi
56+
57+
exec bash "$SCRIPT_DIR/deploy/deploy.sh" "${FORWARD_ARGS[@]}"

deploy/docker/generate_env.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ DEPLOY_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
88
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
99
ENV_FILE="${DEPLOYMENT_ROOT_ENV:-$PROJECT_ROOT/.env}"
1010
ENV_EXAMPLE="$PROJECT_ROOT/.env.example"
11+
LEGACY_ENV="$PROJECT_ROOT/docker/.env"
1112
LEGACY_ENV_EXAMPLE="$PROJECT_ROOT/docker/.env.example"
1213

13-
echo " 📁 Target .env location: $ENV_FILE"
14+
if [ "${NEXENT_GENERATE_ENV_SKIP_MAIN:-false}" != "true" ]; then
15+
echo " 📁 Target .env location: $ENV_FILE"
16+
fi
1417

1518
update_env_var() {
1619
local key="$1"
@@ -41,6 +44,10 @@ prepare_env_file() {
4144

4245
if [ -f "$ENV_FILE" ]; then
4346
echo " ✅ Using existing root .env"
47+
elif [ -f "$LEGACY_ENV" ]; then
48+
echo " root .env not found, copying docker/.env..."
49+
cp "$LEGACY_ENV" "$ENV_FILE"
50+
echo " Created root .env from docker/.env"
4451
elif [ -f "$ENV_EXAMPLE" ]; then
4552
echo " 📋 root .env not found, copying .env.example..."
4653
cp "$ENV_EXAMPLE" "$ENV_FILE"
@@ -50,7 +57,7 @@ prepare_env_file() {
5057
cp "$LEGACY_ENV_EXAMPLE" "$ENV_FILE"
5158
echo " ✅ Created root .env from docker/.env.example"
5259
else
53-
echo " ERROR Neither root .env nor .env.example exists"
60+
echo " ERROR Neither root .env nor docker/.env nor .env.example exists"
5461
ERROR_OCCURRED=1
5562
return 1
5663
fi
@@ -167,4 +174,6 @@ main() {
167174
}
168175

169176
# Run main function
170-
main "$@"
177+
if [ "${NEXENT_GENERATE_ENV_SKIP_MAIN:-false}" != "true" ]; then
178+
main "$@"
179+
fi

deploy/docker/uninstall.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,30 @@ resolve_delete_volumes() {
165165
[[ "$answer" =~ ^[Yy]$ ]]
166166
}
167167

168+
remove_docker_named_volumes() {
169+
command -v docker >/dev/null 2>&1 || return 0
170+
171+
local volume_names
172+
volume_names="$(docker volume ls --format '{{.Name}}' 2>/dev/null || true)"
173+
[ -n "$volume_names" ] || return 0
174+
175+
local volumes_to_remove=()
176+
local volume
177+
while IFS= read -r volume; do
178+
[ -n "$volume" ] || continue
179+
case "$volume" in
180+
nexent_*|nexent-*|monitor_*)
181+
volumes_to_remove+=("$volume")
182+
;;
183+
esac
184+
done <<< "$volume_names"
185+
186+
if [ "${#volumes_to_remove[@]}" -gt 0 ]; then
187+
echo "🧹 Removing Docker volumes: ${volumes_to_remove[*]}"
188+
docker volume rm -f "${volumes_to_remove[@]}" >/dev/null 2>&1 || true
189+
fi
190+
}
191+
168192
docker_compose_down_file() {
169193
local compose_file="$1"
170194
local use_project_name="$2"
@@ -190,6 +214,7 @@ docker_compose_down_file() {
190214

191215
remove_nexent_data_dirs() {
192216
local root_dir="${ROOT_DIR:-$HOME/nexent-data}"
217+
local work_dir="$HOME/nexent"
193218
root_dir="${root_dir%/}"
194219

195220
if [ -z "$root_dir" ] || [ "$root_dir" = "/" ]; then
@@ -205,6 +230,8 @@ remove_nexent_data_dirs() {
205230
"$root_dir/volumes"
206231
"$root_dir/openssh-server"
207232
"$root_dir/scripts"
233+
"$root_dir/skills"
234+
"$work_dir"
208235
)
209236

210237
local dir
@@ -238,6 +265,7 @@ main() {
238265
docker_compose_down_file "$COMPOSE_DIR/docker-compose.yml" true "$remove_volumes"
239266

240267
if [ "$remove_volumes" = "true" ]; then
268+
remove_docker_named_volumes
241269
remove_nexent_data_dirs
242270
fi
243271

0 commit comments

Comments
 (0)