From f35b04096db38bf426e92783560bec71eb6599c4 Mon Sep 17 00:00:00 2001 From: wxy <3050128610@qq.com> Date: Thu, 21 May 2026 22:39:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=BF=87=E7=A8=8B=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=BF=9B=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy.sh | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/deploy.sh b/deploy.sh index f498277..6e9963a 100644 --- a/deploy.sh +++ b/deploy.sh @@ -244,53 +244,18 @@ build_single_image() { next_stage stage_header "$label" "$est_sec" - # 创建临时文件捕获构建日志 - local logfile - logfile=$(mktemp /tmp/youdu-wiki-build-XXXXXX.log) - - # 在后台构建 - docker compose -f "$COMPOSE_FILE" build --progress=plain "$service" >"$logfile" 2>&1 & - local build_pid=$! - - # 显示旋转动画,监控构建日志中的关键行 - start_spinner "构建中 (可另开终端查看: tail -f $logfile)" - local last_summary="" - while kill -0 "$build_pid" 2>/dev/null; do - # 尝试从日志中提取当前步骤 - local current_step - current_step=$(grep -E "^\s*#\d+|^\s*\[.*\]|^#\d+.*RUN|DONE|CACHED|ERROR" "$logfile" 2>/dev/null | tail -1 || true) - if [ -n "$current_step" ] && [ "$current_step" != "$last_summary" ]; then - last_summary="$current_step" - # 清理 spinner 行,打印步骤信息 - printf "\r\033[K ${DIM}→ %s${NC}\n" "$(echo "$current_step" | sed 's/^[[:space:]]*//' | cut -c1-80)" - start_spinner "构建中" - fi - sleep 1 - done - stop_spinner - - # 检查构建结果 - wait "$build_pid" + # Docker 默认输出自带进度条 [1/6] [2/6] 等,直接显示到终端 + docker compose -f "$COMPOSE_FILE" build "$service" 2>&1 local exit_code=$? local elapsed=$(( $(date +%s) - STAGE_START )) if [ $exit_code -eq 0 ]; then - clear_line printf " ${GREEN}✓${NC} %s ${DIM}(耗时 %s)${NC}\n" "$label 构建成功" "$(format_time $elapsed)" else - clear_line printf " ${RED}✗${NC} %s ${DIM}(耗时 %s)${NC}\n" "$label 构建失败" "$(format_time $elapsed)" - echo "" - echo -e " ${RED}构建日志 (最后 30 行):${NC}" - echo " ─────────────────────────────────────────" - tail -30 "$logfile" | while IFS= read -r line; do echo " $line"; done - echo " ─────────────────────────────────────────" - echo " 完整日志: $logfile" - rm -f "$logfile" exit 1 fi - rm -f "$logfile" } # ============================================