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,