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 |
31
.drone.yml
31
.drone.yml
@ -26,7 +26,7 @@ steps:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: security-scan
|
- name: security-scan
|
||||||
image: aquasec/trivy:latest
|
image: ghcr.io/aquasecurity/trivy:0.69.3
|
||||||
commands:
|
commands:
|
||||||
- trivy image --input image.tar --severity HIGH,CRITICAL --exit-code 1
|
- trivy image --input image.tar --severity HIGH,CRITICAL --exit-code 1
|
||||||
|
|
||||||
@ -37,31 +37,16 @@ steps:
|
|||||||
from_secret: GITEA_TOKEN
|
from_secret: GITEA_TOKEN
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache git
|
- apk add --no-cache git
|
||||||
|
|
||||||
# Git konfigurieren
|
|
||||||
- git config --global user.email "drone@ci.local"
|
- git config --global user.email "drone@ci.local"
|
||||||
- git config --global user.name "Drone CI"
|
- git config --global user.name "Drone CI"
|
||||||
|
# Erst clonen
|
||||||
# Remote setzen
|
- git clone https://git.efi.th-nuernberg.de/gitea/niegratschkato95684/EinfuehrungInDocker_Pipeline2.git
|
||||||
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
- cd EinfuehrungInDocker_Pipeline2
|
||||||
|
# Dann Remote mit Token setzen (Wichtig: $$ für Drone)
|
||||||
# Repo clonen
|
- git remote set-url origin https://niegratschkato95684:$${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/niegratschkato95684/EinfuehrungInDocker_Pipeline2.git
|
||||||
- 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 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 .
|
- cp $DRONE_WORKSPACE/image.tar .
|
||||||
- git add 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 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
|
|
||||||
39
Dockerfile
39
Dockerfile
@ -1,22 +1,33 @@
|
|||||||
# Base-Image
|
# Stage 1: Builder
|
||||||
FROM ubuntu:latest
|
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
|
# Stage 2: Runtime
|
||||||
RUN apt-get update
|
FROM alpine:3.20
|
||||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
# 1. Non-Root User erstellen
|
||||||
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||||
|
|
||||||
# Arbeitsverzeichnis setzen
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# alles kopieren
|
# 2. Binary kopieren
|
||||||
COPY . .
|
COPY --from=builder /app/deployment .
|
||||||
|
|
||||||
# Code kompilieren
|
# 3. Verzeichnis für Volume erstellen und Berechtigungen setzen
|
||||||
RUN gcc -o deployment deployment.c
|
RUN mkdir /output && chown appuser:appgroup /output
|
||||||
|
|
||||||
# Verzeichnis für Ausgabe anlegen
|
# 4. Zum Non-Root User wechseln
|
||||||
RUN mkdir /output
|
USER appuser
|
||||||
|
|
||||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
VOLUME ["/output"]
|
||||||
ENTRYPOINT ["/bin/bash", "-c"]
|
|
||||||
|
# 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"]
|
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||||
Loading…
x
Reference in New Issue
Block a user