fix: correct Python dependencies path for non-root user in Docker

The builder stage installed dependencies to /root/.local but the final
stage switched to the 'aegis' user who couldn't access /root/.local.

Fixed by copying dependencies to /home/aegis/.local and updating PATH
to point to the correct location.
This commit is contained in:
2026-01-29 20:24:30 +01:00
parent 9e2ff4cec8
commit 0d986eb78b

View File

@@ -22,25 +22,24 @@ FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Copy Python dependencies from builder
COPY --from=builder /root/.local /root/.local
# Create non-root user for security
RUN useradd -m -u 1000 -s /bin/bash aegis
# Copy Python dependencies from builder to aegis user's home
COPY --from=builder --chown=aegis:aegis /root/.local /home/aegis/.local
# Copy application code
COPY src/ ./src/
COPY --chown=aegis:aegis src/ ./src/
# Create directory for audit logs
RUN mkdir -p /var/log/aegis-mcp && \
chmod 755 /var/log/aegis-mcp
# Create non-root user for security
RUN useradd -m -u 1000 -s /bin/bash aegis && \
chown -R aegis:aegis /app /var/log/aegis-mcp
chown -R aegis:aegis /var/log/aegis-mcp
# Switch to non-root user
USER aegis
# Add user's local bin to PATH
ENV PATH=/root/.local/bin:$PATH
ENV PATH=/home/aegis/.local/bin:$PATH
ENV PYTHONPATH=/app/src:$PYTHONPATH
# Expose MCP server port