fix: correct file ownership for non-root user in Docker
Add --chown=appuser:appuser to COPY commands in runtime stage to ensure the appuser can read the copied files. Without this, Python fails with PermissionError when importing modules.
This commit is contained in:
@@ -28,10 +28,10 @@ RUN useradd --create-home --shell /bin/bash appuser
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy virtual environment from builder
|
# Copy virtual environment from builder
|
||||||
COPY --from=builder /app/.venv /app/.venv
|
COPY --from=builder --chown=appuser:appuser /app/.venv /app/.venv
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY --from=builder /app/src ./src
|
COPY --from=builder --chown=appuser:appuser /app/src ./src
|
||||||
|
|
||||||
# Set environment
|
# Set environment
|
||||||
ENV PATH="/app/.venv/bin:$PATH"
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
|
|||||||
Reference in New Issue
Block a user