Compare commits
8 Commits
main
...
drone-arti
| Author | SHA1 | Date | |
|---|---|---|---|
| c674a12f9e | |||
| ac7628e92c | |||
| 65f7568d94 | |||
| fd7cd93357 | |||
| db3dfa6b4e | |||
| 7aed6a2669 | |||
| 1bfd977d6f | |||
| 10fbaaaf8f |
@ -46,8 +46,8 @@ 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/meyerjo94774/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
|
||||||
|
|||||||
61
Dockerfile
61
Dockerfile
@ -1,22 +1,57 @@
|
|||||||
# Base-Image
|
# Multi-Stage Build
|
||||||
FROM ubuntu:latest
|
|
||||||
|
|
||||||
# Pakete installieren
|
# ============================================
|
||||||
RUN apt-get update
|
# Build Stage
|
||||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
# ============================================
|
||||||
|
FROM cgr.dev/chainguard/wolfi-base:latest AS build
|
||||||
|
|
||||||
# Arbeitsverzeichnis setzen
|
# Nur die benötigten Pakete installieren mit --no-chache
|
||||||
|
RUN apk add --no-cache build-base
|
||||||
|
|
||||||
|
# WORKDIR setzen
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# alles kopieren
|
# Source Code kopieren
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Code kompilieren
|
# Compile
|
||||||
RUN gcc -o deployment deployment.c
|
RUN gcc -o deployment deployment.c
|
||||||
|
|
||||||
# Verzeichnis für Ausgabe anlegen
|
# ============================================
|
||||||
RUN mkdir /output
|
# Runtime Stage
|
||||||
|
# ============================================
|
||||||
|
FROM cgr.dev/chainguard/wolfi-base:latest AS runtime
|
||||||
|
|
||||||
|
# Curl für den HEALTHCHECK
|
||||||
|
RUN apk add --no-cache curl
|
||||||
|
|
||||||
|
# Das output directory erstellen
|
||||||
|
RUN mkdir -p /output
|
||||||
|
|
||||||
|
# User ohne Root-Rechte erstellen
|
||||||
|
RUN adduser -D app
|
||||||
|
|
||||||
|
# Der User app braucht die Rechte für den Ordner output
|
||||||
|
RUN chown -R app:app /output
|
||||||
|
|
||||||
|
# Das Binary aus der Build-Stage kopieren
|
||||||
|
COPY --from=build /app/deployment /app/deployment
|
||||||
|
|
||||||
|
# WORKDIR setzen
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
#output als Mount angeben
|
||||||
|
VOLUME ["/output"]
|
||||||
|
|
||||||
|
# Auf den app User wechseln
|
||||||
|
USER app
|
||||||
|
|
||||||
|
# Programm starten
|
||||||
|
ENTRYPOINT ["/bin/sh", "-c"]
|
||||||
|
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||||
|
|
||||||
|
# prüfen ob output.txt existiert und aktualisiert wird
|
||||||
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||||
|
CMD [ -f /output/output.txt ] && \
|
||||||
|
[ $(find /output/output.txt -mmin -1 | wc -l) -gt 0 ] || exit 1
|
||||||
|
|
||||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
|
||||||
ENTRYPOINT ["/bin/bash", "-c"]
|
|
||||||
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
|
||||||
Loading…
x
Reference in New Issue
Block a user