forked from freudenreichan/EinfuehrungInDocker_Pipeline2
This commit is contained in:
parent
f3629abddf
commit
78c168f9de
41
Dockerfile
41
Dockerfile
@ -1,41 +1,34 @@
|
||||
# -----------------------
|
||||
# 1. BUILD STAGE
|
||||
# -----------------------
|
||||
FROM alpine:latest AS builder
|
||||
FROM alpine:3.20
|
||||
|
||||
# gcc installieren
|
||||
RUN apk add --no-cache gcc musl-dev
|
||||
|
||||
# Arbeitsverzeichnis
|
||||
WORKDIR /app
|
||||
|
||||
# Dateien kopieren
|
||||
COPY deployment.c .
|
||||
|
||||
# Programm kompilieren
|
||||
RUN gcc -O2 -o deployment deployment.c
|
||||
|
||||
|
||||
# -----------------------
|
||||
# 2. RUNTIME STAGE
|
||||
# -----------------------
|
||||
FROM alpine:latest
|
||||
|
||||
# Sicherheitsuser anlegen
|
||||
# Non-root User
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# nur Binary übernehmen
|
||||
COPY --from=builder /app/deployment /app/deployment
|
||||
|
||||
# Output-Verzeichnis
|
||||
RUN mkdir /output && chown -R appuser:appgroup /output /app
|
||||
|
||||
# Non-root User
|
||||
USER appuser
|
||||
|
||||
# Volume für Ausgabe
|
||||
# Datavolume
|
||||
VOLUME ["/output"]
|
||||
|
||||
# Healthcheck (angepasst an dein Programm)
|
||||
# Falls es nur einmal läuft: alternative prüfen (siehe Hinweis unten)
|
||||
HEALTHCHECK --interval=30s --timeout=3s \
|
||||
CMD test -f /output/output.txt || exit 1
|
||||
# User wechseln
|
||||
USER appuser
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK CMD test -f /output/output.txt || exit 1
|
||||
|
||||
# Anwendung starten
|
||||
CMD ["/bin/sh", "-c", "./deployment 10 > /output/output.txt"]
|
||||
|
||||
# Start
|
||||
CMD ["/app/deployment", "10"]
|
||||
Loading…
x
Reference in New Issue
Block a user