Files
kefu/deploy/knowledge-batch-20261007/server-bundle/02-build.sh
T
2026-11-16 09:39:42 +08:00

22 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 构建候选镜像 + 离线跑测试 + 核对候选镜像文件。线上服务不受影响。
set -euo pipefail
test "${REMOTE_RELEASE_APPROVED:-}" = knowledge-batch-20261007
release=/home/ps/knowledge-batch-20261007
cd "$release"
test -f preflight-complete
test ! -e candidate-passed
python3 remote_server_guard.py baseline > /dev/null
test "$(docker image inspect zyt/wecom-admin:before-knowledge-batch-20261007 --format '{{.Id}}')" = "$(cat image-before.txt)"
docker build --network=none --pull=false -f Dockerfile.overlay -t zyt/wecom-admin:knowledge-batch-20261007 . > candidate-build.log 2>&1
# serverTestModules 随包放在 tests/;imageTestModules 用镜像自带的测试文件(PYTHONPATH 后一项)。
# -P:不把工作目录 /app/wechat_rpa 放到 sys.path 最前面,否则镜像里同名的旧测试会盖住随包的新测试。
mapfile -t modules < <(python3 -c 'import json;p=json.load(open("release-plan.json"));print("\n".join(p["serverTestModules"]+p.get("imageTestModules",[])))')
test "${#modules[@]}" -gt 0
docker run --rm --network=none --read-only --tmpfs /tmp:size=512m,mode=1777 --tmpfs /data:size=256m,mode=1777 \
-v "$release/tests:/release-tests:ro" -e PYTHONPATH=/release-tests:/app/wechat_rpa \
zyt/wecom-admin:knowledge-batch-20261007 python -X utf8 -B -P -m unittest "${modules[@]}" -q > candidate-tests.log 2>&1
tail -n 3 candidate-tests.log
python3 remote_server_guard.py candidate
printf '%s\n' passed > candidate-passed