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 36 additions and 32 deletions

View File

@ -37,16 +37,31 @@ steps:
from_secret: GITEA_TOKEN
commands:
- apk add --no-cache git
# Git konfigurieren
- git config --global user.email "drone@ci.local"
- git config --global user.name "Drone CI"
# Erst clonen
- git clone https://git.efi.th-nuernberg.de/gitea/niegratschkato95684/EinfuehrungInDocker_Pipeline2.git
- cd EinfuehrungInDocker_Pipeline2
# Dann Remote mit Token setzen (Wichtig: $$ für Drone)
- git remote set-url origin https://niegratschkato95684:$${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/niegratschkato95684/EinfuehrungInDocker_Pipeline2.git
# Remote setzen
#- 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
# Branch wechseln oder erstellen
- git checkout drone-artifacts || git checkout -b drone-artifacts
- git rm image.tar || echo "image.tar not found"
# 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"
- git push origin drone-artifacts
# Pull vor Push (um Konflikte zu vermeiden)
- git pull || true
# Push
- git push

View File

@ -1,33 +1,22 @@
# Stage 1: Builder
FROM alpine:3.20 AS builder
RUN apk add --no-cache build-base
WORKDIR /app
COPY deployment.c .
# Statisches Linken ist wichtig für 'scratch' oder 'alpine'
RUN gcc -O2 -static -s -o deployment deployment.c
# Base-Image
FROM ubuntu:latest
# Stage 2: Runtime
FROM alpine:3.20
# 1. Non-Root User erstellen
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Pakete installieren
RUN apt-get update
RUN apt-get install -y build-essential gcc curl vim net-tools
# Arbeitsverzeichnis setzen
WORKDIR /app
# 2. Binary kopieren
COPY --from=builder /app/deployment .
# alles kopieren
COPY . .
# 3. Verzeichnis für Volume erstellen und Berechtigungen setzen
RUN mkdir /output && chown appuser:appgroup /output
# Code kompilieren
RUN gcc -o deployment deployment.c
# 4. Zum Non-Root User wechseln
USER appuser
# Verzeichnis für Ausgabe anlegen
RUN mkdir /output
VOLUME ["/output"]
# Healthcheck: Prüft, ob die Datei existiert und Inhalt hat
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD test -s /output/output.txt || exit 1
ENTRYPOINT ["/bin/sh", "-c"]
# Die Anwendung schreibt in das gemountete Volume
# Ausgabe wird ins Container-Dateisystem geschrieben
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]