Dockerfile aktualisiert
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Tobias Niegratschka 2026-05-05 07:51:30 +00:00
parent fd5c8099ef
commit 76dfa617d2

View File

@ -1,40 +1,33 @@
# syntax=docker/dockerfile:1
############################
# 1) Builder: compilen
############################
# Stage 1: Builder
FROM alpine:3.20 AS builder
WORKDIR /app
# Build-Tools nur im Builder
RUN apk add --no-cache build-base
# Nur die C-Datei kopieren
WORKDIR /app
COPY deployment.c .
# Kompilieren (statisch linken)
# Statisches Linken ist wichtig für 'scratch' oder 'alpine'
RUN gcc -O2 -static -s -o deployment deployment.c
############################
# 2) Runtime: Minimaler Footprint
############################
# Stage 2: Runtime
FROM alpine:3.20
# 1. Non-Root User erstellen
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app
# Binary vom Builder kopieren
# 2. Binary kopieren
COPY --from=builder /app/deployment .
# Verzeichnis für das Volume erstellen
RUN mkdir /output
# 3. Verzeichnis für Volume erstellen und Berechtigungen setzen
RUN mkdir /output && chown appuser:appgroup /output
# 4. Zum Non-Root User wechseln
USER appuser
# Datavolume mounten (leitet die Ausgabe nach außen)
VOLUME ["/output"]
# Healthcheck: Prüft, ob die Datei existiert und nicht leer ist
# Healthcheck: Prüft, ob die Datei existiert und Inhalt hat
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD test -s /output/output.txt || exit 1
ENTRYPOINT ["/bin/sh", "-c"]
# Die Anwendung schreibt in das gemountete Volume
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]