forked from freudenreichan/EinfuehrungInDocker_Pipeline2
Compare commits
No commits in common. "drone-artifacts" and "main" have entirely different histories.
drone-arti
...
main
24
.drone.yml
24
.drone.yml
@ -42,20 +42,26 @@ steps:
|
|||||||
- 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"
|
||||||
|
|
||||||
# Eigenes Repo klonen (mit Token-Auth)
|
# Remote setzen
|
||||||
- git clone https://kesslerpe96777:$GITEA_TOKEN@git.efi.th-nuernberg.de/gitea/kesslerpe96777/EinfuehrungInDocker_Pipeline2.git
|
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
||||||
- cd EinfuehrungInDocker_Pipeline2
|
|
||||||
|
|
||||||
# Branch wechseln oder neu erstellen
|
# Repo clonen
|
||||||
|
- 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
|
||||||
|
|
||||||
# Altes Artifact löschen (|| true falls noch nicht da)
|
# Artifact löschen und neu hinzufügen
|
||||||
- git rm image.tar || true
|
- 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
|
# 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"
|
||||||
|
|
||||||
# Push (-u beim ersten Mal damit der neue Branch upstream gesetzt wird)
|
# Pull vor Push (um Konflikte zu vermeiden)
|
||||||
- git push -u origin drone-artifacts
|
- git pull || true
|
||||||
|
|
||||||
|
# Push
|
||||||
|
- git push
|
||||||
45
Dockerfile
45
Dockerfile
@ -1,8 +1,9 @@
|
|||||||
# Base-Image
|
# Base-Image
|
||||||
FROM alpine:3.23 AS builder
|
FROM ubuntu:latest
|
||||||
|
|
||||||
# Pakete installieren + Updates einspielen
|
# Pakete installieren
|
||||||
RUN apk upgrade --no-cache && apk add --no-cache gcc musl-dev
|
RUN apt-get update
|
||||||
|
RUN apt-get install -y build-essential gcc curl vim net-tools
|
||||||
|
|
||||||
# Arbeitsverzeichnis setzen
|
# Arbeitsverzeichnis setzen
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@ -11,37 +12,11 @@ WORKDIR /app
|
|||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Code kompilieren
|
# Code kompilieren
|
||||||
RUN gcc -O2 -o deployment deployment.c
|
RUN gcc -o deployment deployment.c
|
||||||
|
|
||||||
|
# Verzeichnis für Ausgabe anlegen
|
||||||
|
RUN mkdir /output
|
||||||
|
|
||||||
# Base-Image
|
# Ausgabe wird ins Container-Dateisystem geschrieben
|
||||||
FROM alpine:3.23
|
ENTRYPOINT ["/bin/bash", "-c"]
|
||||||
|
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||||
# Sicherheitsupdates einspielen
|
|
||||||
RUN apk upgrade --no-cache
|
|
||||||
|
|
||||||
# Arbeitsverzeichnis setzen
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# kompiliertes Programm kopieren
|
|
||||||
COPY --from=builder /app/deployment /app/deployment
|
|
||||||
|
|
||||||
# Verzeichnis für Ausgabe anlegen + User erstellen
|
|
||||||
RUN addgroup -S appuser \
|
|
||||||
&& adduser -S appuser -G appuser \
|
|
||||||
&& mkdir /output \
|
|
||||||
&& chown -R appuser:appuser /app /output
|
|
||||||
|
|
||||||
# Datavolume für Ausgabe
|
|
||||||
VOLUME ["/output"]
|
|
||||||
|
|
||||||
# nicht als root laufen
|
|
||||||
USER appuser
|
|
||||||
|
|
||||||
# Healthcheck
|
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
||||||
CMD test -s /output/output.txt || exit 1
|
|
||||||
|
|
||||||
# Ausgabe wird ins Volume geschrieben
|
|
||||||
ENTRYPOINT ["/bin/sh", "-c"]
|
|
||||||
CMD ["touch /output/output.txt && ./deployment 10 >> /output/output.txt & tail -f /output/output.txt"]
|
|
||||||
22
Dockerfile2
22
Dockerfile2
@ -1,22 +0,0 @@
|
|||||||
# Base-Image
|
|
||||||
FROM ubuntu:latest
|
|
||||||
|
|
||||||
# Pakete installieren
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
|
||||||
|
|
||||||
# Arbeitsverzeichnis setzen
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# alles kopieren
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Code kompilieren
|
|
||||||
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"]
|
|
||||||
Loading…
x
Reference in New Issue
Block a user