Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f1c6307316 | |||
| 90e6d5b445 | |||
| 9da2e37910 | |||
| 978a622c77 | |||
| 2bee80e0b6 | |||
| 7a1193be40 | |||
| 7e9e14e5d3 |
28
.drone.yml
28
.drone.yml
@ -33,35 +33,33 @@ steps:
|
||||
- name: push-artifact
|
||||
image: alpine:latest
|
||||
environment:
|
||||
# Das Secret muss in Drone unter diesem Namen angelegt sein!
|
||||
GITEA_TOKEN:
|
||||
from_secret: GITEA_TOKEN
|
||||
commands:
|
||||
- apk add --no-cache git
|
||||
|
||||
# Git konfigurieren
|
||||
# Git Identität setzen
|
||||
- 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 direkt mit Token clonen (oauth2 ist der Standard-User für Gitea-Tokens)
|
||||
- git clone https://oauth2:$${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
|
||||
- cd EinfuehrungInDocker_Pipeline2
|
||||
|
||||
# Repo clonen
|
||||
- git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
|
||||
- cd EinfuehrungInDocker_Pipeline
|
||||
|
||||
# Branch wechseln oder erstellen
|
||||
# Branch wechseln oder lokal erstellen
|
||||
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
||||
|
||||
# Artifact löschen und neu hinzufügen
|
||||
- git rm image.tar
|
||||
# Die Datei aus dem vorherigen Kaniko-Step in das Repo-Verzeichnis kopieren
|
||||
- git rm --ignore-unmatch image.tar
|
||||
- cp $DRONE_WORKSPACE/image.tar .
|
||||
- git add image.tar
|
||||
|
||||
# Commit nur wenn Änderungen vorhanden
|
||||
# Commit erstellen (falls sich nichts geändert hat, geht es dank || echo weiter)
|
||||
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
|
||||
|
||||
# Pull vor Push (um Konflikte zu vermeiden)
|
||||
- git pull || true
|
||||
# Pull versucht den Remote-Stand zu holen, falls der Branch auf Gitea schon existiert
|
||||
- git pull origin drone-artifacts || true
|
||||
|
||||
# Push
|
||||
- git push
|
||||
# Jetzt klappt der Push, weil die URL oben das Token enthält
|
||||
- git push --set-upstream origin drone-artifacts
|
||||
|
||||
26
Dockerfile
26
Dockerfile
@ -1,9 +1,8 @@
|
||||
# Base-Image
|
||||
FROM ubuntu:latest
|
||||
FROM alpine:latest
|
||||
|
||||
# Pakete installieren
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y build-essential gcc curl vim net-tools
|
||||
# Pakete installieren (alpine nutzt apk anstelle von apt-get!)
|
||||
RUN apk update && apk add --no-cache build-base gcc curl vim net-tools
|
||||
|
||||
# Arbeitsverzeichnis setzen
|
||||
WORKDIR /app
|
||||
@ -17,6 +16,21 @@ RUN gcc -o deployment deployment.c
|
||||
# Verzeichnis für Ausgabe anlegen
|
||||
RUN mkdir /output
|
||||
|
||||
# Neuen nicht root-user anlegen und diesem die Rechte
|
||||
# fuer die Arbeitsverzeichnisse geben
|
||||
RUN addgroup -S newgroup && adduser -S newuser -G newgroup
|
||||
RUN chown -R newuser:newgroup /app /output
|
||||
# Benutzer wechseln
|
||||
USER newuser
|
||||
|
||||
# Mount-Punkt fuer Laufzeit festlegen
|
||||
VOLUME /output
|
||||
|
||||
# Healthcheck anlegen
|
||||
# - prueft alle 10s ob die Datei output.txt erfolgreich erstellt wurde
|
||||
# - wenn 'test -f' fehlschlaegt, wird der Container als 'unhealthy' markiert
|
||||
HEALTHCHECK --interval=10s --timeout=3s CMD test -f /output/output.txt || exit 1
|
||||
|
||||
# Ausgabe wird ins Container-Dateisystem geschrieben
|
||||
ENTRYPOINT ["/bin/bash", "-c"]
|
||||
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||
ENTRYPOINT ["/bin/sh", "-c"]
|
||||
CMD ["./deployment 10 > /output/output.txt && tail -f /output/output.txt"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user