forked from freudenreichan/EinfuehrungInDocker_Pipeline2
Some checks failed
continuous-integration/drone/push Build is failing
69 lines
2.0 KiB
YAML
69 lines
2.0 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: ghcr.io/aquasecurity/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"
|
|
|
|
# Variable für die URL mit Token definieren (erleichtert Wartung)
|
|
- export REPO_URL="https://oauth2:$$GITEA_TOKEN@git.efi.th-nuernberg.de/gitea/katzenbergeran87461/EinfuehrungInDocker_Pipeline2.git"
|
|
|
|
# Remote setzen
|
|
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/katzenbergeran87461/EinfuehrungInDocker_Pipeline2
|
|
|
|
# Repo clonen
|
|
- git clone $REPO_URL
|
|
- cd EinfuehrungInDocker_Pipeline2
|
|
|
|
# Branch wechseln oder erstellen
|
|
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
|
|
|
# Artifact ersetzen bzw. neu hinzufügen
|
|
- cp $DRONE_WORKSPACE/image.tar .
|
|
- git add image.tar
|
|
|
|
# Commit nur wenn Änderungen vorhanden
|
|
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
|
|
|
|
# Pull vor Push (um Konflikte zu vermeiden)
|
|
- git pull $REPO_URL drone-artifacts || true
|
|
|
|
# Push
|
|
- git push $REPO_URL drone-artifacts |