Tanja Kuerzdoerfer 0d85c95672
Some checks failed
continuous-integration/drone/push Build is failing
Dockerfile aktualisiert
2026-04-18 09:31:55 +00:00

40 lines
1.2 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

FROM alpine:latest
# Nur notwendige Build-Tools installieren + sofort aufräumen
RUN apk add --no-cache build-base && \
rm -rf /var/cache/apk/*
# Non-root User + Gruppe anlegen (hohe UID/GID für bessere Security)
RUN addgroup -S -g 10001 appgroup && \
adduser -S -u 10001 -G appgroup -h /app -s /bin/sh appuser
WORKDIR /app
# Quellcode als root kopieren (COPY --chown funktioniert zuverlässig)
COPY --chown=appuser:appgroup . .
# Als non-root User kompilieren
USER appuser
RUN gcc -o deployment deployment.c -O2 -static # -static macht das Binary robuster
# ← WICHTIG: Hier wieder zurück zu root, um /output zu erstellen + chown
USER root
# Ausgabe-Verzeichnis als root anlegen und dem appuser geben
RUN mkdir -p /output && \
chown -R appuser:appgroup /output && \
chmod 755 /output
# HEALTHCHECK (läuft als root das ist bei HEALTHCHECK erlaubt und empfohlen)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD pgrep -x deployment > /dev/null || exit 1
# Volume deklarieren (wird beim Start mit -v gemountet)
VOLUME ["/output"]
# Endgültig als non-root User starten
USER appuser
# Startbefehl
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["./deployment 10 > /output/output.txt 2>&1 && exec tail -f /output/output.txt"]