Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0077c88c1 | ||
|
|
68dbda9735 | ||
|
|
b30e07243d | ||
|
|
79d3a4e215 | ||
|
|
c14b87eab9 | ||
|
|
f9d668d8db | ||
|
|
94e5dea293 | ||
|
|
9412b817db | ||
|
|
c216710a49 | ||
|
|
d8a7158df3 | ||
|
|
de063f1886 | ||
|
|
566e564e77 | ||
|
|
66b927f8e0 | ||
|
|
4fd2f73dfe | ||
|
|
d175700588 | ||
|
|
7a785a8232 | ||
|
|
0c6a661fb8 | ||
|
|
d428dbab16 | ||
|
|
9cc4bc497e | ||
|
|
e1f496dd3b | ||
|
|
cb70c06352 | ||
|
|
ff11abc459 | ||
|
|
81ea75e54c |
+12
-19
@@ -26,7 +26,7 @@ steps:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: security-scan
|
- name: security-scan
|
||||||
image: aquasec/trivy:latest
|
image: aquasec/trivy:0.69.3
|
||||||
commands:
|
commands:
|
||||||
- trivy image --input image.tar --severity HIGH,CRITICAL --exit-code 1
|
- trivy image --input image.tar --severity HIGH,CRITICAL --exit-code 1
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ steps:
|
|||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
environment:
|
environment:
|
||||||
GITEA_TOKEN:
|
GITEA_TOKEN:
|
||||||
from_secret: GITEA_TOKEN
|
from_secret: drone_token
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache git
|
- apk add --no-cache git
|
||||||
|
|
||||||
@@ -42,26 +42,19 @@ steps:
|
|||||||
- git config --global user.email "drone@ci.local"
|
- git config --global user.email "drone@ci.local"
|
||||||
- git config --global user.name "Drone CI"
|
- git config --global user.name "Drone CI"
|
||||||
|
|
||||||
# Remote setzen
|
# Das fertige Image kurz zwischenspeichern
|
||||||
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
- cp image.tar /tmp/image.tar
|
||||||
|
|
||||||
# Repo clonen
|
# Informationen holen und in den Branch wechseln
|
||||||
- git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
|
- git fetch origin
|
||||||
- cd EinfuehrungInDocker_Pipeline
|
|
||||||
|
|
||||||
# Branch wechseln oder erstellen
|
|
||||||
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
||||||
|
|
||||||
# Artifact löschen und neu hinzufügen
|
# Das Image zurückholen
|
||||||
- git rm image.tar
|
- cp /tmp/image.tar ./image.tar
|
||||||
- cp $DRONE_WORKSPACE/image.tar .
|
|
||||||
- git add image.tar
|
|
||||||
|
|
||||||
# Commit nur wenn Änderungen vorhanden
|
# Datei committen
|
||||||
|
- git add image.tar
|
||||||
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
|
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
|
||||||
|
|
||||||
# Pull vor Push (um Konflikte zu vermeiden)
|
# DER FINALE TRICK: Direkt mit Username + Token an die Ziel-URL pushen
|
||||||
- git pull || true
|
- git push https://$$GITEA_TOKEN@git.efi.th-nuernberg.de/gitea/nowakke92618/EinfuehrungInDocker_Pipeline2.git drone-artifacts
|
||||||
|
|
||||||
# Push
|
|
||||||
- git push
|
|
||||||
+32
-18
@@ -1,22 +1,36 @@
|
|||||||
# Base-Image
|
# === STAGE 1: Die Bau-Umgebung (wird am Ende weggeworfen) ===
|
||||||
FROM ubuntu:latest
|
FROM alpine:latest AS builder
|
||||||
|
RUN apk add --no-cache build-base
|
||||||
# Pakete installieren
|
WORKDIR /build
|
||||||
RUN apt-get update
|
COPY deployment.c .
|
||||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
# Hier wird die fertige, ausführbare Binärdatei erzeugt
|
||||||
|
|
||||||
# Arbeitsverzeichnis setzen
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# alles kopieren
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Code kompilieren
|
|
||||||
RUN gcc -o deployment deployment.c
|
RUN gcc -o deployment deployment.c
|
||||||
|
|
||||||
# Verzeichnis für Ausgabe anlegen
|
# === STAGE 2: Die schlanke Laufzeit-Umgebung (das finale Image) ===
|
||||||
|
FROM alpine:latest
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Nur das fertige C-Programm aus Stage 1 herüberkopieren (spart ~150MB!)
|
||||||
|
COPY --from=builder /build/deployment .
|
||||||
|
|
||||||
|
# Verzeichnis für die Ausgabe anlegen
|
||||||
RUN mkdir /output
|
RUN mkdir /output
|
||||||
|
|
||||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
# Anforderung 1: Datavolume für die Ausgabe definieren
|
||||||
ENTRYPOINT ["/bin/bash", "-c"]
|
VOLUME /output
|
||||||
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
|
||||||
|
# Anforderung 2 & 3: Nicht-Root-User anlegen & Schreibrechte für /output vergeben
|
||||||
|
RUN adduser -D appuser && chown -R appuser:appuser /app /output
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
# Anforderung 4: Funktionsfähiger HEALTHCHECK
|
||||||
|
# Er prüft alle 10 Sekunden, ob das Programm die Datei erfolgreich beschreibt
|
||||||
|
HEALTHCHECK --interval=10s --timeout=3s \
|
||||||
|
CMD test -f /output/output.txt || exit 1
|
||||||
|
|
||||||
|
# Da wir auf Alpine sind, nutzen wir /bin/sh (spart die Installation von bash)
|
||||||
|
ENTRYPOINT ["/bin/sh", "-c"]
|
||||||
|
|
||||||
|
# Das '&' (statt '&&') sorgt dafür, dass das C-Programm im Hintergrund startet,
|
||||||
|
# damit das 'tail -f' im Vordergrund sofort anspringt und dem User Feedback gibt!
|
||||||
|
CMD ["./deployment 10 > /output/output.txt & tail -f /output/output.txt"]
|
||||||
Reference in New Issue
Block a user