From 525c4339376611950dcc418d53a94d3baefb301d Mon Sep 17 00:00:00 2001 From: Wang Zhuoxuan Date: Fri, 17 Apr 2026 16:20:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=9B=E5=BB=BA=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E9=A2=84=E7=BD=AE=E7=9A=84=20bun=20=E7=94=A8?= =?UTF-8?q?=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - oven/bun:1.3 已包含 bun 用户,无需重复创建 - chown 使用 bun:bun 而非 bun:nodejs --- Dockerfile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9e8be1b..6b75bc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,21 +23,19 @@ RUN bun run build FROM oven/bun:1.3 AS release WORKDIR /app -# 创建非 root 用户(Debian 兼容命令) -RUN groupadd --system --gid 1001 nodejs && \ - useradd --system --uid 1001 --gid nodejs --no-create-home --shell /usr/sbin/nologin bun - # 安装 curl(用于健康检查) RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/* +# oven/bun 镜像已预置 bun 用户 (uid 1001),直接使用 + # 复制生产依赖和构建产物 COPY --from=install /app/node_modules ./node_modules COPY --from=build /app/dist ./dist COPY --from=build /app/db ./db COPY --from=build /app/package.json ./ -# 设置权限 -RUN chown -R bun:nodejs /app +# 设置权限(bun 用户已存在,使用其默认组) +RUN chown -R bun:bun /app USER bun # 暴露端口