From 375a0453aeba22bf430f7ab364a56ba5394dfa9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AF=92=E5=AF=92?= <2596194220@qq.com> Date: Sun, 24 May 2026 23:20:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=B9=E5=99=A8=E5=86=85=E4=BB=A5=20r?= =?UTF-8?q?oot=20=E8=BF=90=E8=A1=8C=E4=BB=A5=E8=AE=BF=E9=97=AE=20Docker=20?= =?UTF-8?q?socket=EF=BC=8Cdocker=20compose=20=E6=94=B9=E4=B8=BA=20docker-c?= =?UTF-8?q?ompose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 6 ++++-- lib/update.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3379e26..835a942 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,8 +54,10 @@ RUN chown -R nextjs:nodejs /app # 安装 git(版本检查、拉取更新)和 docker CLI(构建/重启容器) USER root RUN apk add --no-cache git docker-cli docker-compose -RUN chown -R nextjs:nodejs /app -USER nextjs +# 以 root 运行以确保有权限访问挂载的 Docker socket /var/run/docker.sock +# 若需以非 root 运行,需在宿主机上执行: +# sudo chmod 666 /var/run/docker.sock +# 或在容器入口脚本中动态匹配 socket 的 group GID EXPOSE 3000 ENV PORT=3000 diff --git a/lib/update.ts b/lib/update.ts index 092fc34..9bfeec4 100644 --- a/lib/update.ts +++ b/lib/update.ts @@ -297,7 +297,7 @@ export async function executeUpdate( // 3. 构建新镜像 onLog("[3/4] 构建新 Docker 镜像"); - execSync(`cd "${tmpDir}" && docker compose -p recipe_tool build`, { + execSync(`cd "${tmpDir}" && docker-compose -p recipe_tool build`, { encoding: "utf-8", timeout: 600000, windowsHide: true, @@ -307,7 +307,7 @@ export async function executeUpdate( // 4. 重启服务 onLog("[4/4] 重启服务"); - execSync(`cd "${tmpDir}" && docker compose -p recipe_tool up -d`, { + execSync(`cd "${tmpDir}" && docker-compose -p recipe_tool up -d`, { encoding: "utf-8", timeout: 60000, windowsHide: true,