Compare commits

..

No commits in common. "drone-artifacts" and "main" have entirely different histories.

3 changed files with 20 additions and 45 deletions

View File

@ -20,7 +20,6 @@ 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
@ -33,11 +32,9 @@ steps:
- name: push-artifact
image: alpine:latest
environment:
GITEA_TOKEN:
from_secret: GITEA_TOKEN
commands:
- apk add --no-cache git
@ -45,28 +42,26 @@ steps:
- git config --global user.email "drone@ci.local"
- git config --global user.name "Drone CI"
# Eigenes Repository mit Token clonen
- git clone https://oauth2:$GITEA_TOKEN@git.efi.th-nuernberg.de/gitea/spiesol91009/EinfuehrungInDocker_Pipeline2_OS.git
# Remote setzen
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
# In Repository wechseln
- cd EinfuehrungInDocker_Pipeline2_OS
# 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
# Vorhandenes Artifact entfernen (falls vorhanden)
- git rm image.tar || true
# Neues Artifact kopieren
# Artifact löschen und neu hinzufügen
- git rm image.tar
- cp $DRONE_WORKSPACE/image.tar .
# Datei hinzufügen
- git add image.tar
# Commit nur bei Änderungen
# Commit nur wenn Änderungen vorhanden
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
# Branch pushen
- git push --set-upstream origin drone-artifacts
# Pull vor Push (um Konflikte zu vermeiden)
- git pull || true
# Push
- git push

View File

@ -1,8 +1,9 @@
# ---------- Build Stage ----------
FROM alpine:latest AS build
# Base-Image
FROM ubuntu:latest
# Pakete installieren
RUN apk add --no-cache build-base
RUN apt-get update
RUN apt-get install -y build-essential gcc curl vim net-tools
# Arbeitsverzeichnis setzen
WORKDIR /app
@ -13,30 +14,9 @@ COPY . .
# Code kompilieren
RUN gcc -o deployment deployment.c
# ---------- 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
RUN mkdir /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"]
# Ausgabe wird ins Container-Dateisystem geschrieben
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]

BIN
image.tar

Binary file not shown.