Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2943da897 | |||
| 7daec37e62 | |||
| fca43e2ff2 | |||
| bdc4592eb4 | |||
| ecfcb3efa3 | |||
| 6f34e1354c | |||
| 2b85e26179 | |||
| a42486619c | |||
| ed5ee6a367 |
@ -46,8 +46,8 @@ steps:
|
||||
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
||||
|
||||
# Repo clonen
|
||||
- git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
|
||||
- cd EinfuehrungInDocker_Pipeline
|
||||
- git clone https://git.efi.th-nuernberg.de/gitea/allamaaki80515/EinfuehrungInDocker_Pipeline2.git
|
||||
- cd EinfuehrungInDocker_Pipeline2
|
||||
|
||||
# Branch wechseln oder erstellen
|
||||
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
||||
|
||||
35
Dockerfile
35
Dockerfile
@ -1,22 +1,47 @@
|
||||
# Base-Image
|
||||
FROM ubuntu:latest
|
||||
#FROM ubuntu:latest
|
||||
|
||||
# Pakete installieren
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
||||
#RUN apt-get update && apt-get install -y build-essential gcc curl vim net-tools
|
||||
|
||||
# Stage 1: Bauen (mit Alpine + gcc)
|
||||
FROM alpine:3.19 AS build-env
|
||||
|
||||
# Pakete installieren
|
||||
RUN apk add --no-cache gcc musl-dev
|
||||
|
||||
# Arbeitsverzeichnis setzen
|
||||
WORKDIR /app
|
||||
|
||||
# alles kopieren
|
||||
COPY . .
|
||||
# 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
|
||||
|
||||
# Verzeichnis für Ausgabe anlegen
|
||||
RUN mkdir /output
|
||||
|
||||
# Nicht-Root-User anlegen
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
RUN chown appuser:appgroup /output
|
||||
|
||||
# Nur die fertige Binary aus Stage 1 übernehmen
|
||||
COPY --from=build-env /app/deployment /app/deployment
|
||||
|
||||
# Volume für Ausgabe
|
||||
VOLUME ["/output"]
|
||||
|
||||
# Non-root User setzen
|
||||
USER appuser
|
||||
|
||||
# Healthcheck: prüft ob das Output-Verzeichnis erreichbar ist
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD test -d /output || exit 1
|
||||
|
||||
# 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