AriStockAI/build-and-push.sh
fanfpy 49cac43f4f refactor(build): 移除前端服务的特殊构建逻辑
前端服务的构建已迁移至独立的构建流程,因此从通用构建脚本中移除相关代码
2025-07-17 12:50:16 +08:00

51 lines
1.3 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.

#!/bin/bash
set -e
# 固定版本号为latest
VERSION="latest"
REGISTRY="crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com"
NAMESPACE="testrrr"
USERNAME="2324802641zhengniannian@gmail.com"
SERVICES=("data-service" "emotion-service" "frontend" "quant-service" "recommend-service" "user-service")
# 登录阿里云Docker仓库
echo "登录阿里云Docker仓库..."
docker login --username=$USERNAME $REGISTRY
if [ $? -ne 0 ]; then
echo "登录失败,请检查用户名和密码"
exit 1
fi
# 构建并推送所有服务镜像
for service in "${SERVICES[@]}"; do
echo "\n==================== 处理 $service ===================="
SERVICE_DIR="services/$service"
IMAGE_NAME="$REGISTRY/$NAMESPACE/$service:$VERSION"
# 检查服务目录是否存在
if [ ! -d "$SERVICE_DIR" ]; then
echo "错误: 服务目录 $SERVICE_DIR 不存在"
exit 1
fi
# 构建Docker镜像
echo "正在构建镜像: $IMAGE_NAME"
docker build -t $IMAGE_NAME $SERVICE_DIR
if [ $? -ne 0 ]; then
echo "镜像构建失败"
exit 1
fi
# 推送Docker镜像
echo "正在推送镜像: $IMAGE_NAME"
docker push $IMAGE_NAME
if [ $? -ne 0 ]; then
echo "镜像推送失败"
exit 1
fi
echo "$service 处理完成"
done
echo "\n所有服务镜像构建和推送成功完成"
exit 0