From f3138e9681ab6ac0363e7ee07b314dc91caa38fd Mon Sep 17 00:00:00 2001 From: djteang <935037887@qq.com> Date: Sun, 21 Sep 2025 01:23:06 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=E9=95=9C=E5=83=8F=E5=81=A5=E5=BA=B7?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index eb2ec89..ad88675 100644 --- a/Dockerfile +++ b/Dockerfile @@ -89,13 +89,7 @@ RUN corepack enable && corepack prepare pnpm@latest --activate && \ # 清理安装缓存减小镜像大小 pnpm store prune -# 切回非特权用户 -USER nextjs - -# 暴露HTTP和WebSocket端口 -EXPOSE 3000 3001 - -# 创建健康检查脚本 +# 创建健康检查脚本(在切换用户之前以root权限创建) RUN echo '#!/usr/bin/env node\n\ const http = require("http");\n\ const options = {\n\ @@ -129,7 +123,14 @@ req.on("timeout", () => {\n\ \n\ req.setTimeout(5000);\n\ req.end();' > /app/healthcheck.js && \ - chmod +x /app/healthcheck.js + chmod +x /app/healthcheck.js && \ + chown nextjs:nodejs /app/healthcheck.js + +# 切回非特权用户 +USER nextjs + +# 暴露HTTP和WebSocket端口 +EXPOSE 3000 3001 # 添加健康检查 HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \