🔐 SECURITY FIX: Container laeuft jetzt als Non-Root (appuser) statt root!
docker-build-and-push / build (push) Failing after 1m7s

This commit is contained in:
KI-Sparringpartner
2026-08-03 16:30:18 +02:00
parent f6d2bd3b39
commit c6c527c011
+13 -7
View File
@@ -1,17 +1,23 @@
# Build stage (optional hier für jetzt reicht)
# Build stage
FROM python:3.12-slim
WORKDIR /app
# Git und System-Tools installieren (ESSENTIUELL!)
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
apt-get install -y git && \
rm -rf /var/lib/apt/lists/* && \
adduser --disabled-password --gecos "" appuser #✅ NEU: Nutzer erstellen!
# Abhängigkeiten installieren
COPY requirements.txt .
# Abhängigkeiten installieren als app-user
RUN chown -R appuser:appuser /app
USER appuser #✅ WICHTIG: Jetzt laeuft der Container als 'appuser'!
COPY --chown=appuser:appuser requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Applikation kopieren
COPY app/ ./app
COPY --chown=appuser:appuser app/ ./app
# Setze PYTHONPATH damit Imports funktionieren
ENV PYTHONPATH=/app
@@ -19,5 +25,5 @@ ENV PYTHONPATH=/app
# Exponierter Port
EXPOSE 8000
# Starte den Server
# Starte den Server als Nicht-Root!
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]