forked from freudenreichan/EinfuehrungInDocker_Pipeline2
Some checks failed
continuous-integration/drone/push Build is failing
40 lines
959 B
Docker
40 lines
959 B
Docker
# syntax=docker/dockerfile:1
|
|
|
|
############################
|
|
# 1) Builder: compilen
|
|
############################
|
|
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
|
|
COPY deployment.c .
|
|
|
|
# Kompilieren (statisch linken)
|
|
RUN gcc -O2 -static -s -o deployment deployment.c
|
|
|
|
############################
|
|
# 2) Runtime: Minimaler Footprint
|
|
############################
|
|
FROM alpine:3.20
|
|
|
|
WORKDIR /app
|
|
|
|
# Binary vom Builder kopieren
|
|
COPY --from=builder /app/deployment .
|
|
|
|
# Verzeichnis für das Volume erstellen
|
|
RUN mkdir /output
|
|
|
|
# Datavolume mounten (leitet die Ausgabe nach außen)
|
|
VOLUME ["/output"]
|
|
|
|
# Healthcheck: Prüft, ob die Datei existiert und nicht leer ist
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
|
CMD test -s /output/output.txt || exit 1
|
|
|
|
ENTRYPOINT ["/bin/sh", "-c"]
|
|
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"] |