Kevin Nowak f9d668d8db
Some checks failed
continuous-integration/drone/push Build is failing
.drone.yml aktualisiert
2026-05-17 10:08:11 +00:00

63 lines
1.9 KiB
YAML

kind: pipeline
type: docker
name: default
steps:
- name: build-image
image: gcr.io/kaniko-project/executor:debug
commands:
- /kaniko/executor
--context=.
--dockerfile=Dockerfile
--destination=test-app:latest
--no-push
--tar-path=image.tar
- name: size-check
image: alpine:latest
commands:
- |
SIZE=$(stat -c%s image.tar)
SIZE_MB=$((SIZE / 1024 / 1024))
echo "Image size: ${SIZE_MB}MB"
if [ "$SIZE_MB" -gt 150 ]; then
echo "Image too large!"
exit 1
fi
- name: security-scan
image: aquasec/trivy:0.69.3
commands:
- trivy image --input image.tar --severity HIGH,CRITICAL --exit-code 1
- name: push-artifact
image: alpine:latest
environment:
GITEA_TOKEN:
from_secret: GITEA_TOKEN
commands:
- apk add --no-cache git
# Git konfigurieren
- git config --global user.email "drone@ci.local"
- git config --global user.name "Drone CI"
# Remote setzen: Jetzt aktiv und MIT dem nötigen Token für die Anmeldung!
- git remote set-url origin https://$${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
# Das fertige Image kurz zwischenspeichern, damit Git es beim Branch-Wechsel nicht löscht
- cp image.tar /tmp/image.tar
# Informationen vom Server holen und in den richtigen Branch wechseln
- git fetch origin
- git checkout drone-artifacts || git checkout -b drone-artifacts
# Das Image aus dem Zwischenspeicher zurückholen
- cp /tmp/image.tar ./image.tar
# Datei für Git bereitstellen und commiten
- git add image.tar
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
# Sicher und direkt in dein Repository pushen
- git push origin drone-artifacts