Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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
|
||||
|
||||
- name: security-scan
|
||||
image: aquasec/trivy:latest
|
||||
image: ghcr.io/aquasecurity/trivy:0.69.3
|
||||
commands:
|
||||
- trivy image --input image.tar --severity HIGH,CRITICAL --exit-code 1
|
||||
|
||||
@ -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
|
||||
44
Dockerfile
44
Dockerfile
@ -1,22 +1,40 @@
|
||||
# Base-Image
|
||||
FROM ubuntu:latest
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# Pakete installieren
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
||||
############################
|
||||
# 1) Builder: compilen
|
||||
############################
|
||||
FROM alpine:3.20 AS builder
|
||||
|
||||
# Arbeitsverzeichnis setzen
|
||||
WORKDIR /app
|
||||
|
||||
# alles kopieren
|
||||
COPY . .
|
||||
# Build-Tools nur im Builder
|
||||
RUN apk add --no-cache build-base
|
||||
|
||||
# Code kompilieren
|
||||
RUN gcc -o deployment deployment.c
|
||||
# Nur die C-Datei kopieren
|
||||
COPY deployment.c .
|
||||
|
||||
# Verzeichnis für Ausgabe anlegen
|
||||
# Kompilieren (statisch linken)
|
||||
RUN gcc -O2 -static -s -o deployment deployment.c
|
||||
|
||||
############################
|
||||
# 2) Runtime: Minimaler Footprint
|
||||
############################
|
||||
FROM alpine:3.20
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Binary vom Builder kopieren
|
||||
COPY --from=builder /app/deployment .
|
||||
|
||||
# Verzeichnis für das Volume erstellen
|
||||
RUN mkdir /output
|
||||
|
||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
||||
ENTRYPOINT ["/bin/bash", "-c"]
|
||||
# Datavolume mounten (leitet die Ausgabe nach außen)
|
||||
VOLUME ["/output"]
|
||||
|
||||
# Healthcheck: Prüft, ob die Datei existiert und nicht leer ist
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD test -s /output/output.txt || exit 1
|
||||
|
||||
ENTRYPOINT ["/bin/sh", "-c"]
|
||||
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||
Loading…
x
Reference in New Issue
Block a user