forked from freudenreichan/EinfuehrungInDocker_Pipeline2
Compare commits
11
Commits
ecfcb3efa3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07d40c1a9b | ||
|
|
23976edfa2 | ||
|
|
6d598b3658 | ||
|
|
8af70d0b73 | ||
|
|
3c2fa9c9d1 | ||
|
|
90ac8902e6 | ||
|
|
c2943da897 | ||
|
|
7daec37e62 | ||
|
|
fca43e2ff2 | ||
|
|
bdc4592eb4 | ||
|
|
1a0fcbbd12 |
+4
-4
@@ -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
|
||||||
|
|
||||||
@@ -46,14 +46,14 @@ steps:
|
|||||||
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
||||||
|
|
||||||
# Repo clonen
|
# Repo clonen
|
||||||
- git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
|
- git clone https://git.efi.th-nuernberg.de/gitea/allamaaki80515/EinfuehrungInDocker_Pipeline2.git
|
||||||
- cd EinfuehrungInDocker_Pipeline
|
- cd EinfuehrungInDocker_Pipeline2
|
||||||
|
|
||||||
# Branch wechseln oder erstellen
|
# Branch wechseln oder erstellen
|
||||||
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
||||||
|
|
||||||
# Artifact löschen und neu hinzufügen
|
# Artifact löschen und neu hinzufügen
|
||||||
- git rm image.tar
|
- rm -f image.tar
|
||||||
- cp $DRONE_WORKSPACE/image.tar .
|
- cp $DRONE_WORKSPACE/image.tar .
|
||||||
- git add image.tar
|
- git add image.tar
|
||||||
|
|
||||||
|
|||||||
+21
-2
@@ -5,8 +5,9 @@
|
|||||||
#RUN apt-get update && apt-get install -y build-essential gcc curl vim net-tools
|
#RUN apt-get update && apt-get install -y build-essential gcc curl vim net-tools
|
||||||
|
|
||||||
# Stage 1: Bauen (mit Alpine + gcc)
|
# Stage 1: Bauen (mit Alpine + gcc)
|
||||||
FROM alpine:3.19 AS build-env
|
FROM alpine:3.21 AS build-env
|
||||||
|
|
||||||
|
# Pakete installieren
|
||||||
RUN apk add --no-cache gcc musl-dev
|
RUN apk add --no-cache gcc musl-dev
|
||||||
|
|
||||||
# Arbeitsverzeichnis setzen
|
# Arbeitsverzeichnis setzen
|
||||||
@@ -18,10 +19,28 @@ COPY deployment.c .
|
|||||||
# Code kompilieren
|
# Code kompilieren
|
||||||
RUN gcc -o deployment deployment.c
|
RUN gcc -o deployment deployment.c
|
||||||
|
|
||||||
|
# Stage 2: Schlankes Runtime-Image
|
||||||
|
FROM alpine:3.21
|
||||||
|
|
||||||
# Verzeichnis für Ausgabe anlegen
|
# Verzeichnis für Ausgabe anlegen
|
||||||
RUN mkdir /output
|
RUN mkdir /output
|
||||||
|
|
||||||
#COPY --from=build-env /app/deployment /app/deployment
|
# Nicht-Root-User anlegen
|
||||||
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||||
|
RUN chown appuser:appgroup /output
|
||||||
|
|
||||||
|
# Nur die fertige Binary aus Stage 1 übernehmen
|
||||||
|
COPY --from=build-env /app/deployment /app/deployment
|
||||||
|
|
||||||
|
# Volume für Ausgabe
|
||||||
|
VOLUME ["/output"]
|
||||||
|
|
||||||
|
# Non-root User setzen
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
# Healthcheck: prüft ob das Output-Verzeichnis erreichbar ist
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||||
|
CMD test -d /output || exit 1
|
||||||
|
|
||||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
# Ausgabe wird ins Container-Dateisystem geschrieben
|
||||||
ENTRYPOINT ["/bin/bash", "-c"]
|
ENTRYPOINT ["/bin/bash", "-c"]
|
||||||
|
|||||||
Reference in New Issue
Block a user