- ci/Dockerfile:基础镜像 20.04 → 22.04(板卡实测为 Orange Pi Jammy, 旧 focal 镜像保留为 h100-power-manager-ci:arm64-focal) - scripts/build-arm64-image.sh:arm64 镜像构建(支持 --force 重建) - scripts/build-arm64.sh:日常交叉编译(产物输出 bin/arm64/,与本地隔离) - scripts/deploy.sh:板卡部署(推送二进制+mission,安装 3 个 systemd 服务) - missions/h100.moos:板卡专用 mission 配置 - .gitignore:忽略 build-arm64/、webassets_gen.h 等构建产物
61 lines
1.9 KiB
Bash
Executable File
61 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
||
#=======================================================================
|
||
# FILE: scripts/build-arm64-image.sh
|
||
# DESC: 一次性构建 arm64 CI 镜像(MOOS-IvP + jsoncpp + GTest)。
|
||
# 构建产物缓存后,日常交叉编译只需 ./scripts/build-arm64.sh。
|
||
#
|
||
# 用法:
|
||
# CI_TOKEN=xxx ./scripts/build-arm64-image.sh # 构建(已存在则跳过)
|
||
# CI_TOKEN=xxx ./scripts/build-arm64-image.sh --force # 强制重新构建
|
||
#
|
||
# 环境变量:
|
||
# CI_TOKEN 内网 Gitea token(拉取 moos-ivp / googletest 镜像,兼容 GITEA_TOKEN)
|
||
#=======================================================================
|
||
|
||
set -euo pipefail
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||
|
||
IMAGE="h100-power-manager-ci:arm64"
|
||
GITEA_TOKEN="${CI_TOKEN:-${GITEA_TOKEN:-}}"
|
||
FORCE=0
|
||
[ "${1:-}" = "--force" ] && FORCE=1
|
||
|
||
if [ -z "${GITEA_TOKEN}" ]; then
|
||
echo "错误: 缺少内网 Gitea token。" >&2
|
||
echo " 请设置: CI_TOKEN=xxx ./scripts/build-arm64-image.sh" >&2
|
||
exit 1
|
||
fi
|
||
|
||
if ! command -v docker >/dev/null 2>&1; then
|
||
echo "错误: 未找到 docker" >&2
|
||
exit 1
|
||
fi
|
||
|
||
if ! docker info >/dev/null 2>&1; then
|
||
echo "错误: 无法连接 docker daemon(是否需要用 sudo?)" >&2
|
||
exit 1
|
||
fi
|
||
|
||
if ! docker buildx version >/dev/null 2>&1; then
|
||
echo "错误: 未找到 buildx。请安装: sudo apt-get install -y docker-buildx" >&2
|
||
exit 1
|
||
fi
|
||
|
||
if [ "${FORCE}" = "0" ] && docker image inspect "${IMAGE}" >/dev/null 2>&1; then
|
||
echo ">>> 已存在镜像 ${IMAGE},跳过构建(如需重建: ${0} --force)"
|
||
exit 0
|
||
fi
|
||
if [ "${FORCE}" = "1" ]; then
|
||
echo ">>> --force: 重新构建镜像 ${IMAGE}"
|
||
fi
|
||
|
||
CI_TOKEN="${GITEA_TOKEN}" docker buildx build \
|
||
--platform linux/arm64 \
|
||
--load \
|
||
--secret id=gitea_token,env=CI_TOKEN \
|
||
-t "${IMAGE}" -f "${PROJECT_ROOT}/ci/Dockerfile" "${PROJECT_ROOT}"
|
||
|
||
echo ">>> 镜像构建完成: ${IMAGE}"
|