shanshanzhong 97187806e1
Some checks failed
CI / build (20.15.1) (push) Failing after 23m15s
refactor(docker): 优化Dockerfile中的用户和组创建命令
使用更简洁的useradd和addgroup命令替代原有写法,保持功能不变但提高可读性
2025-12-07 04:34:21 -08:00

25 lines
634 B
Docker

# Use the official lightweight Bun image
FROM oven/bun:latest AS base
# Set working directory
WORKDIR /app
# Create non-root user and set permissions
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 ./
COPY ./apps/user/.next/static ./apps/user/.next/static
COPY ./apps/user/public ./apps/user/public
# Change ownership to non-root user
RUN chown -R nextjs:nodejs /app
USER nextjs
# Disable Next.js telemetry
ENV NEXT_TELEMETRY_DISABLED=1
# Default command to start the server
CMD ["bun", "apps/user/server.js"]