Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 76dfa617d2 | |||
| fd5c8099ef | |||
| 9db3d2b12e | |||
| 250002354b | |||
| 13ef874674 | |||
| c9420bf68c | |||
| 2583ba4906 | |||
| 290a2c1eab | |||
| f5fbdc5a10 | |||
| b0ad53dc50 | |||
| e124f67610 | |||
| 474dff700d | |||
| 5405a6a208 | |||
| 12c488ead8 | |||
| d525fcaaf4 | |||
| f3769cb32c | |||
| bcd8ec8c3e | |||
| 166acf7d78 | |||
| 577991512b | |||
| 3f7e54837b | |||
| 725af0162e | |||
| 94f387a60c | |||
| 69ef92e42f |
29
.drone.yml
29
.drone.yml
@ -37,31 +37,16 @@ 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"
|
||||
|
||||
# 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
|
||||
# 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
|
||||
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
||||
|
||||
# Artifact löschen und neu hinzufügen
|
||||
- git rm image.tar
|
||||
- git rm image.tar || echo "image.tar not found"
|
||||
- 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"
|
||||
|
||||
# Pull vor Push (um Konflikte zu vermeiden)
|
||||
- git pull || true
|
||||
|
||||
# Push
|
||||
- git push
|
||||
- git push origin drone-artifacts
|
||||
39
Dockerfile
39
Dockerfile
@ -1,22 +1,33 @@
|
||||
# Base-Image
|
||||
FROM ubuntu:latest
|
||||
# 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
|
||||
|
||||
# Pakete installieren
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
||||
# Stage 2: Runtime
|
||||
FROM alpine:3.20
|
||||
# 1. Non-Root User erstellen
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
|
||||
# Arbeitsverzeichnis setzen
|
||||
WORKDIR /app
|
||||
|
||||
# alles kopieren
|
||||
COPY . .
|
||||
# 2. Binary kopieren
|
||||
COPY --from=builder /app/deployment .
|
||||
|
||||
# Code kompilieren
|
||||
RUN gcc -o deployment deployment.c
|
||||
# 3. Verzeichnis für Volume erstellen und Berechtigungen setzen
|
||||
RUN mkdir /output && chown appuser:appgroup /output
|
||||
|
||||
# Verzeichnis für Ausgabe anlegen
|
||||
RUN mkdir /output
|
||||
# 4. Zum Non-Root User wechseln
|
||||
USER appuser
|
||||
|
||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
||||
ENTRYPOINT ["/bin/bash", "-c"]
|
||||
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
|
||||
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||
Loading…
x
Reference in New Issue
Block a user