fix: chown /app directory after user creation
Ensure the /app WORKDIR itself is owned by appuser (not just copied files), preventing runtime failures if the app writes to /app directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -31,7 +31,8 @@ FROM base AS runtime
|
|||||||
|
|
||||||
# Create non-root user before COPY so --chown can reference it.
|
# Create non-root user before COPY so --chown can reference it.
|
||||||
# Using COPY --chown avoids a slow recursive chown on overlay2 (docker/for-linux#388).
|
# Using COPY --chown avoids a slow recursive chown on overlay2 (docker/for-linux#388).
|
||||||
RUN groupadd --system appgroup && useradd --system --gid appgroup --create-home appuser
|
RUN groupadd --system appgroup && useradd --system --gid appgroup --create-home appuser \
|
||||||
|
&& chown appuser:appgroup /app
|
||||||
|
|
||||||
# Copy virtual environment from deps stage
|
# Copy virtual environment from deps stage
|
||||||
COPY --from=deps --chown=appuser:appgroup /app/.venv /app/.venv
|
COPY --from=deps --chown=appuser:appgroup /app/.venv /app/.venv
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ ENV NEXT_PUBLIC_AUTH_MODE=${NEXT_PUBLIC_AUTH_MODE}
|
|||||||
|
|
||||||
# Create non-root user before COPY so --chown can reference it.
|
# Create non-root user before COPY so --chown can reference it.
|
||||||
# Using COPY --chown avoids a slow recursive chown on overlay2 (docker/for-linux#388).
|
# Using COPY --chown avoids a slow recursive chown on overlay2 (docker/for-linux#388).
|
||||||
RUN addgroup -S appgroup && adduser -S -G appgroup appuser
|
RUN addgroup -S appgroup && adduser -S -G appgroup appuser \
|
||||||
|
&& chown appuser:appgroup /app
|
||||||
|
|
||||||
COPY --from=builder --chown=appuser:appgroup /app/.next ./.next
|
COPY --from=builder --chown=appuser:appgroup /app/.next ./.next
|
||||||
# `public/` is optional in Next.js apps; repo may not have it.
|
# `public/` is optional in Next.js apps; repo may not have it.
|
||||||
|
|||||||
Reference in New Issue
Block a user