Add healthcheck
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Andreas Katzenberger 2026-04-15 16:43:02 +02:00
parent 14a87720a8
commit 70302b28c7

View File

@ -36,20 +36,15 @@ COPY --from=builder --chown=1000:1000 /build/deployment /app/
# 3. Ab hier läuft alles als sicherer Non-Root User # 3. Ab hier läuft alles als sicherer Non-Root User
USER 1000 USER 1000
# 4. Data Volume für die Ausgabe mounten # 4. Data Volume für die Ausgabe mounten (um lokal die output.txt zu sehen)
VOLUME ["/output"] VOLUME ["/output"]
# 5. Healthcheck implementieren # 5. Healthcheck
# Da das C-Programm alle 10 Sekunden etwas schreibt, prüfen wir alle 15 Sekunden, # Da das C-Programm alle 10 Sekunden etwas schreibt, prüfen wir alle 15 Sekunden,
# ob die Datei "/output/ausgabe.log" existiert und Daten enthält (-s). # ob die Datei "/output/output.txt" existiert und Daten enthält (-s).
# HEALTHCHECK --interval=15s --timeout=3s --start-period=5s --retries=3 \ HEALTHCHECK --interval=15s --timeout=3s --start-period=5s --retries=3 \
# CMD test -s /output/ausgabe.log || exit 1 CMD test -s /output/output.txt || exit 1
# 6. Startbefehl # 6. Startbefehl
# Wir starten das Programm (Intervall: 10 Sekunden) und hängen die Ausgabe (>>) an die Datei im Volume an.
# (Dein C-Code nutzt netterweise schon fflush(stdout), was perfekt für diese Umleitung ist!)
# CMD ["sh", "-c", "./deployment 10 >> /output/ausgabe.log && tail -f /output/ausgabe.log"]
# Ausgabe wird ins Container-Dateisystem geschrieben
ENTRYPOINT ["/bin/sh", "-c"] ENTRYPOINT ["/bin/sh", "-c"]
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"] CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]