Compare commits
11 Commits
main
...
drone-arti
| Author | SHA1 | Date | |
|---|---|---|---|
| 95c3fd45e4 | |||
| 1bec88d9d5 | |||
| e7cb8709ab | |||
| 816f56475e | |||
| 4cfce386df | |||
| 98e948e360 | |||
| ed7cef53c4 | |||
| 2c7d8c2f60 | |||
| 1ff64cdbad | |||
| 7dac79062f | |||
| df9f066b7c |
11
.drone.yml
11
.drone.yml
@ -46,14 +46,15 @@ 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/weigmi87303/EinfuehrungInDocker_Pipeline2.git
|
||||||
- cd EinfuehrungInDocker_Pipeline
|
- cd EinfuehrungInDocker_Pipeline2
|
||||||
|
- git remote set-url origin https://oauth2:$GITEA_TOKEN@git.efi.th-nuernberg.de/gitea/weigmi87303/EinfuehrungInDocker_Pipeline2.git
|
||||||
|
|
||||||
# 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
|
- git rm -f image.tar || true
|
||||||
- cp $DRONE_WORKSPACE/image.tar .
|
- cp $DRONE_WORKSPACE/image.tar .
|
||||||
- git add image.tar
|
- git add image.tar
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ steps:
|
|||||||
- 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"
|
||||||
|
|
||||||
# Pull vor Push (um Konflikte zu vermeiden)
|
# Pull vor Push (um Konflikte zu vermeiden)
|
||||||
- git pull || true
|
- git pull origin drone-artifacts || true
|
||||||
|
|
||||||
# Push
|
# Push
|
||||||
- git push
|
- git push -u origin drone-artifacts
|
||||||
|
|||||||
41
Dockerfile
41
Dockerfile
@ -1,22 +1,31 @@
|
|||||||
# Base-Image
|
# ── Stage 1: Build ───────────────────────────────────────────────────────────
|
||||||
FROM ubuntu:latest
|
FROM gcc:14-bookworm AS builder
|
||||||
|
|
||||||
# Pakete installieren
|
WORKDIR /build
|
||||||
RUN apt-get update
|
COPY deployment.c .
|
||||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
|
||||||
|
|
||||||
# Arbeitsverzeichnis setzen
|
RUN gcc -O2 -static -o deployment deployment.c
|
||||||
|
|
||||||
|
# ── Stage 2: Runtime ─────────────────────────────────────────────────────────
|
||||||
|
FROM alpine:3.21
|
||||||
|
|
||||||
|
# Alle Pakete auf neuesten Stand bringen → patcht libcrypto3/libssl3 auf 3.3.7-r0
|
||||||
|
RUN apk update && apk upgrade --no-cache
|
||||||
|
|
||||||
|
# Nicht-root-User anlegen
|
||||||
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||||
|
|
||||||
|
# Output-Verzeichnis mit korrekten Rechten anlegen
|
||||||
|
RUN mkdir /output && chown appuser:appgroup /output
|
||||||
|
|
||||||
|
COPY --from=builder /build/deployment /app/deployment
|
||||||
|
|
||||||
|
VOLUME ["/output"]
|
||||||
|
USER appuser
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# alles kopieren
|
HEALTHCHECK --interval=30s --timeout=4s --start-period=10s --retries=3 \
|
||||||
COPY . .
|
CMD test -f /output/output.txt && test -s /output/output.txt || exit 1
|
||||||
|
|
||||||
# Code kompilieren
|
ENTRYPOINT ["/bin/sh", "-c"]
|
||||||
RUN gcc -o deployment deployment.c
|
|
||||||
|
|
||||||
# Verzeichnis für Ausgabe anlegen
|
|
||||||
RUN mkdir /output
|
|
||||||
|
|
||||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
|
||||||
ENTRYPOINT ["/bin/bash", "-c"]
|
|
||||||
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