Some checks failed
CI / build (20.15.1) (push) Failing after 23m15s
使用更简洁的useradd和addgroup命令替代原有写法,保持功能不变但提高可读性
24 lines
615 B
Docker
24 lines
615 B
Docker
# Use the official lightweight Bun image
|
|
FROM oven/bun:latest AS base
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Create a non-root user for running the production application
|
|
RUN groupadd -r -g 1001 nodejs && \
|
|
useradd -r -u 1001 -g nodejs -d /home/nextjs -m nextjs
|
|
|
|
# Change to non-root user
|
|
USER nextjs
|
|
|
|
# Copy necessary files for production
|
|
COPY ./apps/admin/.next/standalone ./
|
|
COPY ./apps/admin/.next/static ./apps/admin/.next/static
|
|
COPY ./apps/admin/public ./apps/admin/public
|
|
|
|
# Disable Next.js telemetry at runtime
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Set default command
|
|
CMD ["bun", "apps/admin/server.js"]
|