Compare commits

..

1 Commits
main ... main

Author SHA1 Message Date
1a0fcbbd12 .drone.yml aktualisiert 2026-04-11 11:45:33 +00:00
2 changed files with 35 additions and 42 deletions

View File

@ -26,7 +26,7 @@ steps:
fi
- name: security-scan
image: aquasec/trivy:0.69.3
image: ghcr.io/aquasecurity/trivy:0.69.3
commands:
- trivy image --input image.tar --severity HIGH,CRITICAL --exit-code 1
@ -34,7 +34,7 @@ steps:
image: alpine:latest
environment:
GITEA_TOKEN:
from_secret: drone_token
from_secret: GITEA_TOKEN
commands:
- apk add --no-cache git
@ -42,19 +42,26 @@ steps:
- git config --global user.email "drone@ci.local"
- git config --global user.name "Drone CI"
# Das fertige Image kurz zwischenspeichern
- cp image.tar /tmp/image.tar
# Remote setzen
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
# Informationen holen und in den Branch wechseln
- git fetch origin
# Repo clonen
- git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
- cd EinfuehrungInDocker_Pipeline
# Branch wechseln oder erstellen
- git checkout drone-artifacts || git checkout -b drone-artifacts
# Das Image zurückholen
- cp /tmp/image.tar ./image.tar
# Datei committen
# Artifact löschen und neu hinzufügen
- git rm image.tar
- cp $DRONE_WORKSPACE/image.tar .
- git add image.tar
# Commit nur wenn Änderungen vorhanden
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
# DER FINALE TRICK: Direkt mit Username + Token an die Ziel-URL pushen
- git push https://$$GITEA_TOKEN@git.efi.th-nuernberg.de/gitea/nowakke92618/EinfuehrungInDocker_Pipeline2.git drone-artifacts
# Pull vor Push (um Konflikte zu vermeiden)
- git pull || true
# Push
- git push

View File

@ -1,36 +1,22 @@
# === STAGE 1: Die Bau-Umgebung (wird am Ende weggeworfen) ===
FROM alpine:latest AS builder
RUN apk add --no-cache build-base
WORKDIR /build
COPY deployment.c .
# Hier wird die fertige, ausführbare Binärdatei erzeugt
RUN gcc -o deployment deployment.c
# Base-Image
FROM ubuntu:latest
# === STAGE 2: Die schlanke Laufzeit-Umgebung (das finale Image) ===
FROM alpine:latest
# Pakete installieren
RUN apt-get update
RUN apt-get install -y build-essential gcc curl vim net-tools
# Arbeitsverzeichnis setzen
WORKDIR /app
# Nur das fertige C-Programm aus Stage 1 herüberkopieren (spart ~150MB!)
COPY --from=builder /build/deployment .
# alles kopieren
COPY . .
# Verzeichnis für die Ausgabe anlegen
# Code kompilieren
RUN gcc -o deployment deployment.c
# Verzeichnis für Ausgabe anlegen
RUN mkdir /output
# Anforderung 1: Datavolume für die Ausgabe definieren
VOLUME /output
# 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"]
# Ausgabe wird ins Container-Dateisystem geschrieben
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]