Dockerfile aktualisiert

This commit is contained in:
Andro Chilab 2026-04-11 11:41:06 +00:00
parent dea458fcb2
commit 763719ee64

View File

@ -1,22 +1,38 @@
# Base-Image # Base-Image - Alpine statt Ubuntu
FROM ubuntu:latest FROM alpine:latest AS build
# Pakete installieren # Build-Tools installieren
RUN apt-get update RUN apk add --no-cache gcc musl-dev
RUN apt-get install -y build-essential gcc curl vim net-tools
# Arbeitsverzeichnis setzen # Arbeitsverzeichnis setzen
WORKDIR /app WORKDIR /app
# alles kopieren # Code kopieren und kompilieren
COPY . . COPY deployment.c .
# Code kompilieren
RUN gcc -o deployment deployment.c RUN gcc -o deployment deployment.c
# Verzeichnis für Ausgabe anlegen # Finales schlankes Image
RUN mkdir /output FROM alpine:latest
# Ausgabe wird ins Container-Dateisystem geschrieben # Nicht als root laufen
ENTRYPOINT ["/bin/bash", "-c"] RUN adduser -D appuser
WORKDIR /app
# Nur das Binary kopieren
COPY --from=build /app/deployment .
# Ausgabeverzeichnis anlegen und Rechte setzen
RUN mkdir /output && chown appuser /output
# Volume für Ausgabe
VOLUME /output
# User wechseln
USER appuser
# Healthcheck
HEALTHCHECK --interval=30s --timeout=5s CMD pgrep deployment || exit 1
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"]