feat: record infrastructure POC baseline

This commit is contained in:
wlx committed 2026-08-06 18:34:56 +08:00
1 parent de384796c4
commit 885db5319f
3 files changed
+131

No files matched your search

+13
View File
@@ -38,6 +38,17 @@ sudo TIMEZONE_NAME=Asia/Shanghai RUN_UPGRADE=1 \
脚本使用 Docker 官方 apt 仓库,默认只对密钥下载强制 IPv4、重试下载并校验官方 GPG 指纹;APT 保持系统网络策略,避免影响现有 Ubuntu 镜像源。不修改网络地址、不自动打开防火墙端口,也不会替代现场重启决策。若出现 /var/run/reboot-required,先记下结果,再重启并重新确认 IP、SSH、磁盘和 Docker。 脚本使用 Docker 官方 apt 仓库,默认只对密钥下载强制 IPv4、重试下载并校验官方 GPG 指纹;APT 保持系统网络策略,避免影响现有 Ubuntu 镜像源。不修改网络地址、不自动打开防火墙端口,也不会替代现场重启决策。若出现 /var/run/reboot-required,先记下结果,再重启并重新确认 IP、SSH、磁盘和 Docker。
若 `docker run --rm hello-world` 在访问 `registry-1.docker.io` 时超时,先确认现场批准使用的镜像代理,再配置 Docker。当前 POC 使用 DaoCloud 公共镜像代理;它只用于解决联网适配,不替代生产环境的私有镜像仓库:
~~~bash
cd /srv/ai-soulmate-local-deployment
DOCKER_REGISTRY_MIRROR=https://docker.m.daocloud.io \
./scripts/configure-docker-registry-mirror.sh
docker run --rm hello-world
~~~
脚本会保留 `/etc/docker/daemon.json` 中的其他设置、校验新配置、备份旧文件并重启 Docker。已有业务容器时,必须先安排 Docker 重启窗口。正式交付应使用客户可控的镜像仓库,并按 `inventory/` 中记录的 digest 固定镜像内容。
## 3. 放置并核对源码 ## 3. 放置并核对源码
源码与部署仓库分开,例如: 源码与部署仓库分开,例如:
@@ -81,6 +92,8 @@ docker compose --env-file compose/.env \
PostgreSQL、Redis 和 MinIO 只绑定到 127.0.0.1。未来业务容器使用 postgres:5432、redis:6379 和 minio:9000,不要把 .env 中的宿主机端口当作容器间地址。MinIO 控制台需要时使用 SSH 隧道,不开放公网管理端口。 PostgreSQL、Redis 和 MinIO 只绑定到 127.0.0.1。未来业务容器使用 postgres:5432、redis:6379 和 minio:9000,不要把 .env 中的宿主机端口当作容器间地址。MinIO 控制台需要时使用 SSH 隧道,不开放公网管理端口。
首次通过健康检查后,执行 `scripts/capture-runtime-snapshot.sh` 保存空载资源基线,并用 `docker image inspect` 将实际拉取到的镜像 digest 写入脱敏的 `inventory/` 清单。原始快照继续保留在服务器的 `results/raw/`,不要提交主机标识、凭据或客户数据。
## 5. 业务部署门槛 ## 5. 业务部署门槛
当前 ai-soulmate-server 的 Dockerfile 只有开发目标,开发 Compose 还挂载源码;压缩包中的 ai-soulmate-server-master 没有可验证的 Git 历史。先完成以下改造,再写应用 Compose: 当前 ai-soulmate-server 的 Dockerfile 只有开发目标,开发 Compose 还挂载源码;压缩包中的 ai-soulmate-server-master 没有可验证的 Git 历史。先完成以下改造,再写应用 Compose:
+37
View File
@@ -0,0 +1,37 @@
captured_at: "2026-08-06T18:26:00+08:00"
host_role: "AI SoulMate POC and hardware adaptation server"
deployment_repository_commit: "de38479"
compose_file: "compose/docker-compose.infra.yml"
runtime_snapshot: "results/raw/infra-idle-20260806-182600.txt"
runtime_snapshot_tracking: "server-local and git-ignored"
registry:
mirror: "https://docker.m.daocloud.io"
direct_docker_hub_result: "connection timeout"
mirror_pull_result: "passed"
images:
- service: postgres
configured_reference: "postgres:16-alpine"
immutable_reference: "postgres@sha256:57c72fd2a128e416c7fcc499958864df5301e940bca0a56f58fddf30ffc07777"
- service: redis
configured_reference: "redis:7-alpine"
immutable_reference: "redis@sha256:e7723ff73d963f5cc6d9c4643ea3d989527a402a319239054e9472a7fb9219a2"
- service: minio
configured_reference: "minio/minio:latest"
immutable_reference: "minio/minio@sha256:14cea493d9a34af32f524e538b8346cf79f3321eff8e708c1e2960462bd8936e"
- service: minio-init
configured_reference: "minio/mc:latest"
immutable_reference: "minio/mc@sha256:a7fe349ef4bd8521fb8497f55c6042871b2ae640607cf99d9bede5e9bdf11727"
validation:
compose_config: "passed"
postgres_health: "passed"
redis_health: "passed"
minio_health: "passed"
minio_bucket_initialization: "passed"
notes:
- "No credentials, host identifiers, or customer data are recorded in this inventory."
- "The immutable references record the exact POC images resolved on the server."
- "A release must replace mutable tags in the deployment environment with reviewed immutable references."
+81
View File
@@ -0,0 +1,81 @@
#!/usr/bin/env bash
set -Eeuo pipefail
if [[ "${EUID}" -eq 0 ]]; then
sudo_command=()
else
sudo_command=(sudo)
fi
config_path="${DOCKER_DAEMON_CONFIG:-/etc/docker/daemon.json}"
registry_mirror="${DOCKER_REGISTRY_MIRROR:-https://docker.m.daocloud.io}"
for required_command in cmp jq dockerd systemctl; do
if ! command -v "$required_command" >/dev/null 2>&1; then
printf 'Required command is unavailable: %s\n' "$required_command" >&2
exit 1
fi
done
case "$registry_mirror" in
https://*) ;;
*)
printf 'DOCKER_REGISTRY_MIRROR must use HTTPS: %s\n' "$registry_mirror" >&2
exit 1
;;
esac
current_config="$(mktemp)"
next_config="$(mktemp)"
trap 'rm -f "$current_config" "$next_config"' EXIT
had_config=0
if "${sudo_command[@]}" test -e "$config_path"; then
had_config=1
"${sudo_command[@]}" cat "$config_path" > "$current_config"
else
printf '{}\n' > "$current_config"
fi
jq --arg mirror "$registry_mirror" '
if type != "object" then
error("Docker daemon configuration must be a JSON object")
else
.["registry-mirrors"] = ((.["registry-mirrors"] // []) + [$mirror] | unique)
end
' "$current_config" > "$next_config"
"${sudo_command[@]}" dockerd --validate --config-file="$next_config"
if cmp -s <(jq --sort-keys . "$current_config") <(jq --sort-keys . "$next_config"); then
printf 'Docker registry mirror is already configured: %s\n' "$registry_mirror"
"${sudo_command[@]}" systemctl is-active docker
"${sudo_command[@]}" docker info | sed -n '/Registry Mirrors/,+3p'
exit 0
fi
backup_path=""
if [[ "$had_config" == "1" ]]; then
backup_path="${config_path}.bak-$(date +%Y%m%d-%H%M%S)"
"${sudo_command[@]}" cp --preserve=mode,ownership,timestamps "$config_path" "$backup_path"
fi
"${sudo_command[@]}" install -d -m 0755 "$(dirname -- "$config_path")"
"${sudo_command[@]}" install -m 0644 "$next_config" "$config_path"
if ! "${sudo_command[@]}" systemctl restart docker; then
if [[ -n "$backup_path" ]]; then
"${sudo_command[@]}" install -m 0644 "$backup_path" "$config_path"
else
"${sudo_command[@]}" rm -f "$config_path"
fi
"${sudo_command[@]}" systemctl restart docker || true
printf 'Docker restart failed; the previous daemon configuration was restored.\n' >&2
exit 1
fi
"${sudo_command[@]}" systemctl is-active docker
"${sudo_command[@]}" docker info | sed -n '/Registry Mirrors/,+3p'
if [[ -n "$backup_path" ]]; then
printf 'Previous configuration backup: %s\n' "$backup_path"
fi