test
This commit is contained in:
@@ -197,22 +197,41 @@ deploy_app() {
|
||||
|
||||
log_info "部署应用到: $deploy_dir"
|
||||
|
||||
# 确定要使用的镜像版本
|
||||
if [ "$FAST_BUILD" = true ]; then
|
||||
# 自动检测可用的镜像版本
|
||||
local fast_image=$(docker images "${PROJECT_NAME}:fast" --format "{{.Repository}}:{{.Tag}}" | head -1)
|
||||
local stable_image=$(docker images "${PROJECT_NAME}:stable" --format "{{.Repository}}:{{.Tag}}" | head -1)
|
||||
|
||||
if [ "$FAST_BUILD" = true ] && [ -n "$fast_image" ]; then
|
||||
VERSION="fast"
|
||||
log_info "使用快速构建版本: ${PROJECT_NAME}:fast"
|
||||
else
|
||||
elif [ -n "$stable_image" ]; then
|
||||
VERSION="stable"
|
||||
log_info "使用完整构建版本: ${PROJECT_NAME}:stable"
|
||||
elif [ -n "$fast_image" ]; then
|
||||
VERSION="fast"
|
||||
log_info "找到快速版本,使用: ${PROJECT_NAME}:fast"
|
||||
else
|
||||
log_error "未找到任何可用的镜像"
|
||||
log_error "请先构建镜像: $0 build"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查镜像
|
||||
if ! docker images | grep -q "${PROJECT_NAME}:${VERSION}"; then
|
||||
log_error "镜像 ${PROJECT_NAME}:${VERSION} 不存在,请先构建: $0 build"
|
||||
if [ "$FAST_BUILD" = true ]; then
|
||||
log_error "或使用: $0 build -f"
|
||||
# 检查镜像 - 更可靠的检测方式
|
||||
local image_exists=$(docker images "${PROJECT_NAME}:${VERSION}" --format "{{.Repository}}:{{.Tag}}" | head -1)
|
||||
if [ -z "$image_exists" ]; then
|
||||
log_error "镜像 ${PROJECT_NAME}:${VERSION} 不存在"
|
||||
log_error "请先构建镜像:"
|
||||
if [ "$VERSION" = "fast" ]; then
|
||||
log_error " $0 build -f"
|
||||
else
|
||||
log_error " $0 build"
|
||||
fi
|
||||
echo
|
||||
log_info "可用的镜像列表:"
|
||||
docker images "${PROJECT_NAME}*" --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" 2>/dev/null || echo " 无可用镜像"
|
||||
exit 1
|
||||
else
|
||||
log_success "找到镜像: $image_exists"
|
||||
fi
|
||||
|
||||
# 创建部署目录
|
||||
|
||||
Reference in New Issue
Block a user