Files
kefu/deploy/mobile-http-20260928/server-bundle/02-build.sh
T
2026-09-29 15:52:07 +08:00

23 lines
1.6 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
# 构建候选镜像 + 离线跑测试 + 核对候选镜像文件。线上服务不受影响。
# 本次不改数据库(只改登录的 HTTPS 默认策略和 /m/ 静态文件),不做整库备份;回滚靠旧镜像和 source-before。
set -euo pipefail
test "${REMOTE_RELEASE_APPROVED:-}" = mobile-http-20260928
release=/home/ps/mobile-http-20260928
cd "$release"
test -f preflight-complete
test ! -e candidate-passed
python3 remote_server_guard.py baseline
test "$(docker image inspect zyt/wecom-admin:before-mobile-http-20260928 --format '{{.Id}}')" = "$(cat image-before.txt)"
docker build --network=none --pull=false -f Dockerfile.overlay -t zyt/wecom-admin:mobile-http-20260928 . > 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:mobile-http-20260928 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