You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
2.4 KiB

#!/usr/bin/env bash
# 构建并推送 yunyan-sas 镜像到私有 registry
# 用法:
# ./build.sh # 构建 console + admin,tag=latest
# ./build.sh console # 只构建 console
# ./build.sh admin # 只构建 admin
# TAG=v1.2.3 ./build.sh # 指定版本 tag
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
REGISTRY="${REGISTRY:-docker-registry.ideapsound.com}"
TAG="${TAG:-latest}"
TARGET="${1:-all}"
green() { echo -e "\033[32m$*\033[0m"; }
blue() { echo -e "\033[34m$*\033[0m"; }
red() { echo -e "\033[31m$*\033[0m"; }
# ── 登录 registry ──────────────────────────────────────────
blue ">>> 登录 $REGISTRY ..."
docker login "$REGISTRY" -u admin -p li13451234
# ── 构建 console ───────────────────────────────────────────
build_console() {
local img="$REGISTRY/yunyan-console:$TAG"
blue ">>> 构建 console 镜像: $img"
docker build \
--file "$ROOT/apps/services/Dockerfile.console" \
--tag "$img" \
--platform linux/amd64 \
"$ROOT/apps/services/"
docker push "$img"
green ">>> console 推送完成: $img"
}
# ── 构建 admin ─────────────────────────────────────────────
build_admin() {
local img="$REGISTRY/yunyan-admin:$TAG"
blue ">>> 构建 admin 镜像: $img"
docker build \
--file "$ROOT/apps/admin/Dockerfile" \
--tag "$img" \
--platform linux/amd64 \
"$ROOT/apps/admin/"
docker push "$img"
green ">>> admin 推送完成: $img"
}
# ── 执行 ───────────────────────────────────────────────────
case "$TARGET" in
console) build_console ;;
admin) build_admin ;;
all) build_console; build_admin ;;
*) red "未知目标: $TARGET(可选:console / admin / all)"; exit 1 ;;
esac
echo ""
green "============================================"
green " 镜像构建推送完成 TAG=$TAG"
green " $REGISTRY/yunyan-console:$TAG"
green " $REGISTRY/yunyan-admin:$TAG"
green "============================================"
echo ""
blue "部署命令:"
echo " cd deploy && docker compose pull && docker compose up -d"