From e2937d0ce192288e797da0237ac7ad13ad6108b7 Mon Sep 17 00:00:00 2001 From: aiyimickey <39365912+aiyimickey@users.noreply.github.com> Date: Thu, 2 Jul 2026 17:01:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Docker=20=E6=9E=84=E5=BB=BA=E5=89=8D?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=9B=BF=E6=8D=A2=20shared=20=E7=AC=A6?= =?UTF-8?q?=E5=8F=B7=E9=93=BE=E6=8E=A5=E4=B8=BA=E5=AE=9E=E9=99=85=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docker COPY 无法跟随指向构建上下文外的符号链接, 导致 @shared/* 模块在容器内构建时找不到。 构建前临时替换、构建后恢复。 --- deploy-ai.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deploy-ai.sh b/deploy-ai.sh index ae6626f..8187ed6 100755 --- a/deploy-ai.sh +++ b/deploy-ai.sh @@ -464,8 +464,24 @@ build_on_server() { log "重建容器..." local build_flag="" ssh txjp "test -f $REMOTE_DIR/Dockerfile" 2>/dev/null && build_flag="--build" + + # Docker 无法跟随指向构建上下文外的符号链接,临时将 shared 符号链接替换为实际目录 + ssh txjp "cd $REMOTE_DIR && if [ -L shared ]; then + target=\$(readlink shared) + rm shared + cp -r \$target shared + echo 'shared 符号链接已临时替换为实际目录' + fi" + ssh txjp "cd $REMOTE_DIR && docker compose up -d $build_flag && docker compose restart" + # 恢复 shared 符号链接(仅当目录非符号链接且上级 shared 存在时) + ssh txjp "cd $REMOTE_DIR && if [ -d shared ] && [ ! -L shared ] && [ -d ../shared ]; then + rm -rf shared + ln -s ../shared shared + echo 'shared 符号链接已恢复' + fi" + # 7. 清理构建产生的悬空镜像和缓存(根据磁盘使用率动态调整) log "清理构建缓存..." # 清理悬空镜像(无标签或未被引用的中间层)