From 97187806e131c5827aa3d77f9a2ac25c80be5cfe Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Sun, 7 Dec 2025 04:34:21 -0800 Subject: [PATCH] =?UTF-8?q?refactor(docker):=20=E4=BC=98=E5=8C=96Dockerfil?= =?UTF-8?q?e=E4=B8=AD=E7=9A=84=E7=94=A8=E6=88=B7=E5=92=8C=E7=BB=84?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用更简洁的useradd和addgroup命令替代原有写法,保持功能不变但提高可读性 --- docker/ppanel-admin-web/Dockerfile | 4 ++-- docker/ppanel-user-web/Dockerfile | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/ppanel-admin-web/Dockerfile b/docker/ppanel-admin-web/Dockerfile index 38cd185..0db223c 100644 --- a/docker/ppanel-admin-web/Dockerfile +++ b/docker/ppanel-admin-web/Dockerfile @@ -5,8 +5,8 @@ FROM oven/bun:latest AS base WORKDIR /app # Create a non-root user for running the production application -RUN addgroup --system --gid 1001 nodejs \ - && adduser --system --uid 1001 nextjs +RUN groupadd -r -g 1001 nodejs && \ + useradd -r -u 1001 -g nodejs -d /home/nextjs -m nextjs # Change to non-root user USER nextjs diff --git a/docker/ppanel-user-web/Dockerfile b/docker/ppanel-user-web/Dockerfile index 99cadfd..d01cb49 100644 --- a/docker/ppanel-user-web/Dockerfile +++ b/docker/ppanel-user-web/Dockerfile @@ -5,8 +5,8 @@ FROM oven/bun:latest AS base WORKDIR /app # Create non-root user and set permissions -RUN addgroup --system --gid 1001 nodejs \ - && adduser --system --uid 1001 nextjs +RUN addgroup -r -g 1001 nodejs && \ + useradd -r -u 1001 -g nodejs -d /home/nextjs -m nextjs # Copy build output and static files COPY ./apps/user/.next/standalone ./ @@ -22,4 +22,4 @@ USER nextjs ENV NEXT_TELEMETRY_DISABLED=1 # Default command to start the server -CMD ["bun", "apps/user/server.js"] +CMD ["bun", "apps/user/server.js"] \ No newline at end of file