mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-06 03:30:25 -05:00
🐛 fix(docker): Update Dockerfiles to create non-root user with proper permissions
This commit is contained in:
parent
d5d8d7e0df
commit
1bfebb698a
@ -5,17 +5,21 @@ 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
|
||||
|
||||
# Change to non-root user
|
||||
USER nextjs
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends adduser \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& addgroup --system --gid 1001 nodejs \
|
||||
&& adduser --system --uid 1001 --ingroup nodejs --home /nonexistent --shell /usr/sbin/nologin 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
|
||||
|
||||
# Change to non-root user
|
||||
RUN chown -R nextjs:nodejs /app
|
||||
USER nextjs
|
||||
|
||||
# Disable Next.js telemetry at runtime
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
|
||||
@ -5,17 +5,19 @@ 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 apt-get update \
|
||||
&& apt-get install -y --no-install-recommends adduser \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& addgroup --system --gid 1001 nodejs \
|
||||
&& adduser --system --uid 1001 --ingroup nodejs --home /nonexistent --shell /usr/sbin/nologin 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
|
||||
# Change to non-root user
|
||||
RUN chown -R nextjs:nodejs /app
|
||||
|
||||
USER nextjs
|
||||
|
||||
# Disable Next.js telemetry
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user