Compare commits

...

9 Commits

Author SHA1 Message Date
1a2e510912 Add built Docker image [skip ci] 2026-05-10 14:42:27 +00:00
071e005a11 Add built Docker image [skip ci] 2026-05-10 14:31:21 +00:00
10eba3b2b5 Fix authenticated artifact push 2026-05-10 14:30:03 +00:00
e9e0925d42 Fix artifact branch push 2026-05-10 09:40:41 +00:00
d21396a84c Fix missing image.tar handling 2026-05-10 09:38:29 +00:00
c21b9db028 Fix pipeline directory 2026-05-10 09:36:05 +00:00
68bdfc3a73 Optimize Dockerfile 2026-05-10 09:29:59 +00:00
084f033c87 zurücksetzten 2026-05-09 15:31:39 +00:00
d9b61391d9 Dockerfile optimieren 2026-04-11 13:30:24 +00:00
3 changed files with 46 additions and 21 deletions

View File

@ -20,6 +20,7 @@ steps:
SIZE=$(stat -c%s image.tar)
SIZE_MB=$((SIZE / 1024 / 1024))
echo "Image size: ${SIZE_MB}MB"
if [ "$SIZE_MB" -gt 150 ]; then
echo "Image too large!"
exit 1
@ -32,9 +33,11 @@ steps:
- name: push-artifact
image: alpine:latest
environment:
GITEA_TOKEN:
from_secret: GITEA_TOKEN
commands:
- apk add --no-cache git
@ -42,26 +45,28 @@ steps:
- git config --global user.email "drone@ci.local"
- git config --global user.name "Drone CI"
# Remote setzen
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
# Eigenes Repository mit Token clonen
- git clone https://oauth2:$GITEA_TOKEN@git.efi.th-nuernberg.de/gitea/spiesol91009/EinfuehrungInDocker_Pipeline2_OS.git
# Repo clonen
- git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
- cd EinfuehrungInDocker_Pipeline
# In Repository wechseln
- cd EinfuehrungInDocker_Pipeline2_OS
# Branch wechseln oder erstellen
- git checkout drone-artifacts || git checkout -b drone-artifacts
# Artifact löschen und neu hinzufügen
- git rm image.tar
# Vorhandenes Artifact entfernen (falls vorhanden)
- git rm image.tar || true
# Neues Artifact kopieren
- cp $DRONE_WORKSPACE/image.tar .
# Datei hinzufügen
- git add image.tar
# Commit nur wenn Änderungen vorhanden
# Commit nur bei Änderungen
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
# Pull vor Push (um Konflikte zu vermeiden)
- git pull || true
# Branch pushen
- git push --set-upstream origin drone-artifacts
# Push
- git push

View File

@ -1,9 +1,8 @@
# Base-Image
FROM ubuntu:latest
# ---------- Build Stage ----------
FROM alpine:latest AS build
# Pakete installieren
RUN apt-get update
RUN apt-get install -y build-essential gcc curl vim net-tools
RUN apk add --no-cache build-base
# Arbeitsverzeichnis setzen
WORKDIR /app
@ -14,9 +13,30 @@ COPY . .
# Code kompilieren
RUN gcc -o deployment deployment.c
# Verzeichnis für Ausgabe anlegen
RUN mkdir /output
# Ausgabe wird ins Container-Dateisystem geschrieben
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
# ---------- Runtime Stage ----------
FROM alpine:latest
# Arbeitsverzeichnis setzen
WORKDIR /app
# Benutzer ohne root-Rechte anlegen
RUN adduser -D appuser
# kompiliertes Programm kopieren
COPY --from=build /app/deployment .
# Verzeichnis für Ausgabe anlegen
RUN mkdir /output && chown appuser /output
# Datavolume definieren
VOLUME ["/output"]
# Benutzer wechseln
USER appuser
# HEALTHCHECK
HEALTHCHECK CMD test -f /app/deployment || exit 1
# Ausgabe wird ins Datavolume geschrieben
CMD ["sh", "-c", "./deployment 10 > /output/output.txt && tail -f /output/output.txt"]

BIN
image.tar Normal file

Binary file not shown.