forked from freudenreichan/EinfuehrungInDocker_Pipeline2
This commit is contained in:
parent
90ac8902e6
commit
3c2fa9c9d1
27
Dockerfile
27
Dockerfile
@ -1,17 +1,29 @@
|
||||
# Stage 1: Bauen (mit Alpine + gcc)
|
||||
FROM alpine:3.19 AS build-env
|
||||
# Base-Image
|
||||
#FROM ubuntu:latest
|
||||
|
||||
# Pakete installieren
|
||||
#RUN apt-get update && apt-get install -y build-essential gcc curl vim net-tools
|
||||
|
||||
# Stage 1: Bauen (mit Alpine + gcc)
|
||||
FROM alpine:3.21 AS build-env
|
||||
|
||||
# Pakete installieren
|
||||
RUN apk add --no-cache gcc musl-dev
|
||||
|
||||
# Arbeitsverzeichnis setzen
|
||||
WORKDIR /app
|
||||
|
||||
# alles kopieren --> nur noch deployment.c kopieren!
|
||||
COPY deployment.c .
|
||||
|
||||
# Code kompilieren
|
||||
RUN gcc -o deployment deployment.c
|
||||
|
||||
# Stage 2: Schlankes Runtime-Image
|
||||
FROM alpine:3.19
|
||||
FROM alpine:3.21
|
||||
|
||||
# Output-Verzeichnis erstellen
|
||||
RUN mkdir -p /output
|
||||
# Verzeichnis für Ausgabe anlegen
|
||||
RUN mkdir /output
|
||||
|
||||
# Nicht-Root-User anlegen
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
@ -30,5 +42,6 @@ USER appuser
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD test -d /output || exit 1
|
||||
|
||||
ENTRYPOINT ["/bin/sh", "-c"]
|
||||
CMD ["./app/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