Files
openteam/scripts/build-image.sh
T
SakurasanandClaude ea7f023228 构建: 多架构 Dockerfile + 构建脚本
- Dockerfile 三阶段:前端固定在 BUILDPLATFORM 编译一次(平台无关产物),
  Go 后端按 TARGETARCH 交叉编译,两种架构共用同一份 web/dist
- 前端用 pnpm --ignore-scripts(pnpm≥10 拦截 esbuild/vue-demi postinstall,
  esbuild 走 optionalDependencies 自带二进制),运行镜像非 root + /app/data 卷
- scripts/build-image.sh:--local 本地单架构加载;默认多架构 amd64+arm64 推送

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-18 13:16:54 +08:00

70 lines
1.8 KiB
Bash
Executable File
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
DOCKER_USER="${DOCKER_USER:-openteam}"
VERSION="${VERSION:-$(git describe --tags --always 2>/dev/null || echo latest)}"
PLATFORMS="linux/amd64,linux/arm64"
# --local:本地构建不推送(单架构,加载到本地 docker,tag 不带仓库前缀)
if [[ "${1:-}" == "--local" ]]; then
LOCAL=1
else
LOCAL=0
fi
if [[ $# -gt 1 || ( $# -eq 1 && "$1" != "--local" ) ]]; then
echo "用法: $0 [--local]" >&2
exit 1
fi
native_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "linux/amd64" ;;
aarch64|arm64) echo "linux/arm64" ;;
*) echo "linux/$(uname -m)" ;;
esac
}
if ! docker buildx version &>/dev/null; then
echo "❌ docker buildx 不可用"
exit 1
fi
if ! docker buildx inspect multiarch &>/dev/null 2>&1; then
echo "🔧 创建 multiarch builder..."
docker buildx create --name multiarch --driver docker-container --use
else
docker buildx use multiarch
fi
docker buildx inspect --bootstrap
if [[ $LOCAL -eq 1 ]]; then
PLATFORM="$(native_arch)"
echo ""
echo "========================================"
echo "🚀 本地构建 openteam (${PLATFORM})"
echo " tag: openteam:${VERSION}"
echo "========================================"
docker buildx build \
--platform "${PLATFORM}" \
-t "openteam:${VERSION}" \
-t "openteam:latest" \
--load \
.
echo ""
echo "✅ 完成!openteam:${VERSION}(已加载到本地 docker)"
else
echo ""
echo "========================================"
echo "🚀 构建 openteam (${PLATFORMS})"
echo " tag: ${DOCKER_USER}/openteam:${VERSION}"
echo "========================================"
docker buildx build \
--platform "${PLATFORMS}" \
-t "${DOCKER_USER}/openteam:${VERSION}" \
-t "${DOCKER_USER}/openteam:latest" \
--push \
.
echo ""
echo "✅ 完成!${DOCKER_USER}/openteam:${VERSION}"
fi