docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# 远程部署的路由切换阶段,参数必须是本次已通过内部就绪检查的 Core 容器名。
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
cd /opt/endoleap-infra
|
||||
@@ -8,12 +9,14 @@ live=$1
|
||||
install -d -m 700 dev/foundry-edge
|
||||
edge=dev/foundry-edge
|
||||
route=$edge/foundry.yml
|
||||
# 从现有动态配置提取旧容器;仅在新路由完成 HTTPS 探测后才停止它。
|
||||
previous=
|
||||
if [[ -f "$route" ]]; then
|
||||
previous=$(sed -n 's@.*url: http://\(foundry-core-[a-f0-9]\{12\}\):8080.*@\1@p' "$route")
|
||||
fi
|
||||
backup=$(mktemp)
|
||||
if [[ -f "$route" ]]; then cp "$route" "$backup"; fi
|
||||
# EXIT trap 只恢复动态路由文件或删除新路由,不回滚已执行的数据库迁移/worker/Compose 配置。
|
||||
rollback() {
|
||||
if [[ -s "$backup" ]]; then
|
||||
cp "$backup" "$edge/.restore"
|
||||
@@ -25,6 +28,7 @@ rollback() {
|
||||
}
|
||||
trap rollback EXIT
|
||||
|
||||
# ACME 文件保存证书状态,限制权限;动态路由先写隐藏临时文件再 mv,避免 watcher 读到半文件。
|
||||
touch "$edge/acme.json"
|
||||
chmod 600 "$edge/acme.json"
|
||||
cat > "$edge/.foundry.yml" <<YAML
|
||||
@@ -49,6 +53,7 @@ http:
|
||||
- url: http://$live:8080
|
||||
YAML
|
||||
mv "$edge/.foundry.yml" "$route"
|
||||
# Compose 覆盖文件保持 Traefik 入口、证书与目录 provider 配置,不重建其他服务。
|
||||
cat > foundry-edge.yml <<'YAML'
|
||||
services:
|
||||
traefik:
|
||||
@@ -68,11 +73,13 @@ services:
|
||||
YAML
|
||||
docker compose -p endoleap-dev --env-file dev/env -f compose.yml -f dev.yml -f foundry-edge.yml up -d --no-deps traefik
|
||||
|
||||
# --resolve 在本机回环命中 Traefik,同时保留公开域名 Host/TLS 验证,探测真正的 HTTPS 路由。
|
||||
curl --fail --silent --show-error --output /dev/null --max-time 6 \
|
||||
--retry 15 --retry-delay 4 --retry-all-errors \
|
||||
--resolve api.foundry.entroia.com:443:127.0.0.1 \
|
||||
https://api.foundry.entroia.com/readyz
|
||||
|
||||
# HTTPS 就绪后解除回滚并删除备份;旧容器停止失败仅提示手工清理,不能误报新路由失败。
|
||||
trap - EXIT
|
||||
rm -f "$backup"
|
||||
if [[ "$previous" =~ ^foundry-core-[a-f0-9]{12}$ && "$previous" != "$live" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user