refactor(docker): 优化Dockerfile中的用户和组创建命令
Some checks failed
CI / build (20.15.1) (push) Failing after 23m15s

使用更简洁的useradd和addgroup命令替代原有写法,保持功能不变但提高可读性
This commit is contained in:
shanshanzhong 2025-12-07 04:34:21 -08:00
parent d92202b6ab
commit 97187806e1
2 changed files with 5 additions and 5 deletions

View File

@ -5,8 +5,8 @@ FROM oven/bun:latest AS base
WORKDIR /app WORKDIR /app
# Create a non-root user for running the production application # Create a non-root user for running the production application
RUN addgroup --system --gid 1001 nodejs \ RUN groupadd -r -g 1001 nodejs && \
&& adduser --system --uid 1001 nextjs useradd -r -u 1001 -g nodejs -d /home/nextjs -m nextjs
# Change to non-root user # Change to non-root user
USER nextjs USER nextjs

View File

@ -5,8 +5,8 @@ FROM oven/bun:latest AS base
WORKDIR /app WORKDIR /app
# Create non-root user and set permissions # Create non-root user and set permissions
RUN addgroup --system --gid 1001 nodejs \ RUN addgroup -r -g 1001 nodejs && \
&& adduser --system --uid 1001 nextjs useradd -r -u 1001 -g nodejs -d /home/nextjs -m nextjs
# Copy build output and static files # Copy build output and static files
COPY ./apps/user/.next/standalone ./ COPY ./apps/user/.next/standalone ./