forked from freudenreichan/EinfuehrungInDocker_Pipeline2
Compare commits
No commits in common. "main" and "main" have entirely different histories.
35
Dockerfile
35
Dockerfile
@ -1,19 +1,22 @@
|
||||
# Erster Schritt: App bauen
|
||||
FROM alpine:3.21 AS build
|
||||
RUN apk add --no-cache gcc musl-dev
|
||||
COPY deployment.c .
|
||||
# Base-Image
|
||||
FROM ubuntu:latest
|
||||
|
||||
# Pakete installieren
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
||||
|
||||
# Arbeitsverzeichnis setzen
|
||||
WORKDIR /app
|
||||
|
||||
# alles kopieren
|
||||
COPY . .
|
||||
|
||||
# Code kompilieren
|
||||
RUN gcc -o deployment deployment.c
|
||||
|
||||
# Finales Image: Nur die Binary mitnehmen
|
||||
FROM alpine:3.21
|
||||
RUN apk update && apk upgrade --no-cache
|
||||
# Verzeichnis für Ausgabe anlegen
|
||||
RUN mkdir /output
|
||||
|
||||
# Neuer User wegen Sicherheit
|
||||
RUN adduser -D appuser
|
||||
COPY --from=build /deployment /app/deployment
|
||||
WORKDIR /app
|
||||
RUN mkdir /output && chown appuser /output
|
||||
USER appuser
|
||||
|
||||
# App starten und Output loggen
|
||||
CMD ["/bin/sh", "-c", "./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
||||
ENTRYPOINT ["/bin/bash", "-c"]
|
||||
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||
Loading…
x
Reference in New Issue
Block a user